Context derivation for coefficient coding

ABSTRACT

Coding a transform block having transform coefficients is described. A plurality of register arrays is defined to each hold one or more stored values regarding the coding context based on at least one spatial template for a coding context. The register arrays are initialized by setting the stored values to default values, and values for the transform coefficients from the transform block are coded in a reverse scan order. The values for the transform coefficients are indicative of magnitudes of the transform coefficients. For each of one or more transform coefficients, the coding includes determining the coding context using at least some of the stored values from the register arrays, entropy coding a value for the transform coefficient using the coding context, and updating the register arrays subsequent to entropy coding the value for the transform coefficient.

BACKGROUND

Digital video streams may represent video using a sequence of frames orstill images. Digital video can be used for various applicationsincluding, for example, video conferencing, high definition videoentertainment, video advertisements, or sharing of user-generatedvideos. A digital video stream can contain a large amount of data andconsume a significant amount of computing or communication resources ofa computing device for processing, transmission or storage of the videodata. Various approaches have been proposed to reduce the amount of datain video streams, including compression and other encoding techniques.

SUMMARY

One aspect of the disclosed implementations is a method of coding atransform block having transform coefficients. The method includesdefining, based on at least one spatial template for a coding context,register arrays to each hold one or more stored values regarding thecoding context, wherein the register arrays include at least a firstregister array that has a first size and a second register array thathas a second size that is different than the first size, initializingthe register arrays by setting the stored values to default values, andcoding, in a reverse scan order, values for the transform coefficientsfrom the transform block that are indicative of magnitudes of thetransform coefficients. The coding includes, for each of one or moretransform coefficients, determining the coding context using at leastsome of the stored values from the register arrays, entropy coding avalue for the transform coefficient at a scan position using the codingcontext, and, subsequent to entropy coding the value for the transformcoefficient, updating the register arrays.

Another aspect of the disclosed implementations is an apparatus forcoding a transform block having transform coefficients. The apparatusincludes a memory and a processor configured to execute instructionsstored in the memory. The instructions, when executed, cause theprocessor to define, based on at least one spatial template for a codingcontext, register arrays to each hold one or more stored valuesregarding the coding context, wherein the register arrays include atleast a first register array that has a first size and a second registerarray that has a second size that is different than the first size,initialize the register arrays by setting the stored values to defaultvalues, and code, in a reverse scan order, values for the transformcoefficients from the transform block that are indicative of magnitudesof the transform coefficients. The instructions to code includeinstructions to, for each of one or more transform coefficients,determine the coding context using at least some of the stored valuesfrom the register arrays, entropy code a value for the transformcoefficient at a scan position using the coding context, and update theregister arrays subsequent to entropy coding the value for the transformcoefficient.

Another apparatus for coding a transform block having transformcoefficients that includes a memory and a processor configured toexecute instructions stored in the memory is described. Theinstructions, when executed, cause the processor to define, based on atleast one spatial template for a coding context, register arrays to eachhold one or more stored values regarding the coding context, initializethe register arrays by setting the stored values to default values, andcode values, in a reverse scan order, for the transform coefficients ofthe transform block indicative of magnitudes of the transformcoefficients. The coding instructions includes instructions to determinea first coding context using at least some of the stored values from theregister arrays, entropy code a first value for the transformcoefficient using the first coding context, the first value indicativeof a magnitude of the transform coefficient, and the first valuebelonging to a set of positive integers {0, . . . , a first maximumvalue}, determine a second coding context using at least some of thestored values from the register arrays, entropy code a second value forthe transform coefficient using the second coding context, the secondvalue indicative of the magnitude of the transform coefficient, thesecond value belonging to a set of positive integers {0, . . . , asecond maximum value}, and the second maximum value greater than thefirst maximum value, and, subsequent to entropy coding the first valueand the second value, update the register arrays.

These and other aspects of the present disclosure are disclosed in thefollowing detailed description of the embodiments, the appended claimsand the accompanying figures.

BRIEF DESCRIPTION OF THE DRAWINGS

The description herein makes reference to the accompanying drawingswherein like reference numerals refer to like parts throughout theseveral views.

FIG. 1 is a schematic of a video encoding and decoding system.

FIG. 2 is a block diagram of an example of a computing device that canimplement a transmitting station or a receiving station.

FIG. 3 is a diagram of a video stream to be encoded and subsequentlydecoded.

FIG. 4 is a block diagram of an encoder according to implementations ofthis disclosure.

FIG. 5 is a block diagram of a decoder according to implementations ofthis disclosure.

FIG. 6 is a diagram showing scan orders that can be utilized when codinga block of transform coefficients in accordance with implementations ofthis disclosure.

FIG. 7 is a diagram illustrating the stages of transform coefficientcoding using level maps in accordance with implementations of thisdisclosure.

FIG. 8 is a flowchart diagram of a process for encoding a transformblock in an encoded video bitstream using level maps according to animplementation of this disclosure.

FIG. 9A is a diagram showing a first set of spatial neighboringtemplates that can be utilized in context-based arithmetic codingmethods in accordance with implementations of this disclosure.

FIG. 9B is a diagram showing a second set of spatial neighboringtemplates that can be utilized in context-based arithmetic codingmethods in accordance with implementations of this disclosure.

FIG. 10 is a diagram that shows a first example of a register set thatcorresponds to a horizontal template.

FIG. 11 is a diagram that shows a first example of a register set thatcorresponds to a vertical template.

FIG. 12 is a diagram that shows a first example of a register set thatcorresponds to a two-dimensional template.

FIG. 13 is a diagram that shows a second example of a register set thatcorresponds to a horizontal template.

FIG. 14 is a diagram that shows a second example of a register set thatcorresponds to a vertical template.

FIG. 15 is a diagram that shows a second example of a register set thatcorresponds to a two-dimensional template.

FIG. 16 is a diagram that shows a third example of a register set thatcorresponds to a horizontal template.

FIG. 17 is a diagram that shows a third example of a register set thatcorresponds to a vertical template.

FIG. 18 is a diagram that shows a third example of a register set thatcorresponds to a two-dimensional template.

FIG. 19 is a flowchart diagram of a process for coding a transform blockaccording to an implementation of this disclosure.

FIG. 20 is a flowchart diagram of another process for coding a transformblock according to an implementation of this disclosure.

DETAILED DESCRIPTION

As mentioned above, compression schemes related to coding video streamsmay include breaking images into blocks and generating a digital videooutput bitstream (i.e., an encoded bitstream) using one or moretechniques to limit the information included in the output bitstream. Areceived bitstream can be decoded to re-create the blocks and the sourceimages from the limited information. Encoding a video stream, or aportion thereof, such as a frame or a block, can include using temporalor spatial similarities in the video stream to improve codingefficiency. For example, a current block of a video stream may beencoded based on identifying a difference (residual) between thepreviously coded pixel values, or between a combination of previouslycoded pixel values, and those in the current block.

Encoding using spatial similarities can be known as intra prediction.Intra prediction attempts to predict the pixel values of a block of aframe of video using pixels peripheral to the block; that is, usingpixels that are in the same frame as the block but that are outside theblock. A prediction block resulting from intra prediction is referred toherein as an intra predictor. Intra prediction can be performed along adirection of prediction where each direction can correspond to an intraprediction mode. The intra prediction mode can be signaled by an encoderto a decoder.

Encoding using temporal similarities can be known as inter prediction.Inter prediction attempts to predict the pixel values of a block using apossibly displaced block or blocks from a temporally nearby frame (i.e.,reference frame) or frames. The displacement is identified by a motionvector. A temporally nearby frame is a frame that appears earlier orlater in time in the video stream than the frame of the block beingencoded. Some codecs use up to eight reference frames, which can bestored in a frame buffer. The motion vector can refer to (i.e., use) oneof the reference frames of the frame buffer. As such, one or morereference frames can be available for coding a current frame. Aprediction block resulting from inter prediction is referred to hereinas inter predictor.

As mentioned above, a current block of a video stream may be encodedbased on identifying a difference (residual) between the previouslycoded pixel values and those in the current block. In this way, only theresidual and parameters used to generate the residual need be added tothe encoded bitstream. The residual may be encoded using a lossyquantization step.

The residual block can be in the pixel domain. The residual block can betransformed into a transform domain, resulting in a transform block oftransform coefficients. Herein, the frequency domain is utilized as anexample of the transform domain, but should be construed to refergenerally to the domain in which the values are expressed after beingtransformed, including by Discrete Cosine Transform (DCT) and itsvariants, Discrete Sine Transform (DST) and its variants, and identitytransform or its scaled variants.

The transform coefficients can be quantized resulting in a quantizedtransform block of quantized transform coefficients. The quantizedcoefficients can be entropy encoded and added to an encoded bitstream. Adecoder can receive the encoded bitstream and entropy decode thequantized transform coefficients to reconstruct the original videoframe.

Entropy coding is a technique for “lossless” coding that relies uponprobability models that model the distribution of values occurring in anencoded video bitstream. By using probability models based on a measuredor estimated distribution of values, entropy coding can reduce thenumber of bits required to represent video data close to a theoreticalminimum. In practice, the actual reduction in the number of bitsrequired to represent video data can be a function of the accuracy ofthe probability model, the number of bits over which the coding isperformed, and the computational accuracy of fixed-point arithmetic usedto perform the coding.

In an encoded video bitstream, many of the bits are used for one of twothings: either content prediction (e.g., inter mode/motion vectorcoding, intra prediction mode coding, etc.) or residual coding (e.g.,transform coefficient coding).

With respect to content prediction, the bits in the bitstream caninclude, for a block, the intra prediction mode used to encode theblock. The intra prediction mode can be coded (encoded by an encoder anddecoded by a decoder) using entropy coding. As such, a context isdetermined for the intra prediction mode and a probability model,corresponding to the context, is used for coding the intra predictionmode.

Entropy coding a sequence of symbols is typically achieved by using aprobability model to determine a probability for the sequence and thenusing binary arithmetic coding to map the sequence to a binary codewordat the encoder and to decode that sequence from the binary codeword atthe decoder.

A context model, as used herein, can be a parameter in entropy coding. Acontext model can be any parameter or method that affects probabilityestimation for entropy coding. A purpose of context modeling is toobtain probability distributions for a subsequent entropy coding engine,such as arithmetic coding, Huffman coding, and othervariable-length-to-variable-length coding engines. To achieve goodcompression performance, a large number of contexts may be required. Forexample, some video coding systems can include hundreds or eventhousands of contexts for transform coefficient coding alone. Eachcontext can correspond to a probability distribution.

Residual coding involves transforming residuals for a block of videointo transform blocks of transform coefficients. The transform blocksare in the frequency domain, and one or more transform blocks may begenerated for a block of video. The transform coefficients are quantizedand entropy coded into an encoded video bitstream. A decoder uses theencoded transform coefficients and the reference frames to reconstructthe block. Entropy coding a transform coefficient involves the selectionof a context model (also referred to as probability context model orprobability model) that provides estimates of conditional probabilitiesfor coding the binary symbols of a binarized transform coefficient.

In the implementations of template-based entropy coding of quantizedtransform coefficients that are described herein, spatial templates areused during entropy coding to select context neighbors of the valuebeing coded, and the context neighbors are used to determine the codingcontext. Accessing the values needed for determining the coding contextcan, however, lead to memory bottlenecks. In the implementationsdescribed herein, the values needed for determining the coding contextare held in register arrays within memory, and at least some valuestherein are updated using the most recently coded value, which reducesthe amount of information that must be obtained from base informationsuch as the transform block or level maps. In some embodiments, theseregister arrays may be organized into one or more register sets, wherethe lengths of the arrays (i.e., the number of elements or storedcontext neighbor values) may be different. A register array may comprisea shift register or any other memory where values may be shifted withinand/or between arrays.

Template-based entropy coding of quantized transform coefficients isdescribed herein first with reference to a system in which the teachingsmay be incorporated.

FIG. 1 is a schematic of a video encoding and decoding system 100. Atransmitting station 102 can be, for example, a computer having aninternal configuration of hardware such as that described in FIG. 2.However, other suitable implementations of the transmitting station 102are possible. For example, the processing of the transmitting station102 can be distributed among multiple devices.

A network 104 can connect the transmitting station 102 and a receivingstation 106 for encoding and decoding of the video stream. Specifically,the video stream can be encoded in the transmitting station 102 and theencoded video stream can be decoded in the receiving station 106. Thenetwork 104 can be, for example, the Internet. The network 104 can alsobe a local area network (LAN), wide area network (WAN), virtual privatenetwork (VPN), cellular telephone network or any other means oftransferring the video stream from the transmitting station 102 to, inthis example, the receiving station 106.

The receiving station 106, in one example, can be a computer having aninternal configuration of hardware such as that described in FIG. 2.However, other suitable implementations of the receiving station 106 arepossible. For example, the processing of the receiving station 106 canbe distributed among multiple devices.

Other implementations of the video encoding and decoding system 100 arepossible. For example, an implementation can omit the network 104. Inanother implementation, a video stream can be encoded and then storedfor transmission at a later time to the receiving station 106 or anyother device having memory. In one implementation, the receiving station106 receives (e.g., via the network 104, a computer bus, and/or somecommunication pathway) the encoded video stream and stores the videostream for later decoding. In an example implementation, a real-timetransport protocol (RTP) is used for transmission of the encoded videoover the network 104. In another implementation, a transport protocolother than RTP may be used, e.g., an HTTP-based video streamingprotocol.

When used in a video conferencing system, for example, the transmittingstation 102 and/or the receiving station 106 may include the ability toboth encode and decode a video stream as described below. For example,the receiving station 106 could be a video conference participant whoreceives an encoded video bitstream from a video conference server(e.g., the transmitting station 102) to decode and view and furtherencodes and transmits its own video bitstream to the video conferenceserver for decoding and viewing by other participants.

FIG. 2 is a block diagram of an example of a computing device 200 thatcan implement a transmitting station or a receiving station. Forexample, the computing device 200 can implement one or both of thetransmitting station 102 and the receiving station 106 of FIG. 1. Thecomputing device 200 can be in the form of a computing system includingmultiple computing devices, or in the form of a single computing device,for example, a mobile phone, a tablet computer, a laptop computer, anotebook computer, a desktop computer, and the like.

A CPU 202 in the computing device 200 can be a central processing unit.Alternatively, the CPU 202 can be any other type of device, or multipledevices, capable of manipulating or processing information now-existingor hereafter developed. Although the disclosed implementations can bepracticed with a single processor as shown, e.g., the CPU 202,advantages in speed and efficiency can be achieved using more than oneprocessor.

A memory 204 in the computing device 200 can be a read-only memory (ROM)device or a random access memory (RAM) device in an implementation. Anyother suitable type of storage device can be used as the memory 204. Thememory 204 can include code and data 206 that is accessed by the CPU 202using a bus 212. The memory 204 can further include an operating system208 and application programs 210, the application programs 210 includingat least one program that permits the CPU 202 to perform the methodsdescribed here. For example, the application programs 210 can includeapplications 1 through N, which further include a video codingapplication that performs the methods described here. The computingdevice 200 can also include a secondary storage 214, which can, forexample, be a memory card used with a computing device 200 that ismobile. Because the video communication sessions may contain asignificant amount of information, they can be stored in whole or inpart in the secondary storage 214 and loaded into the memory 204 asneeded for processing.

The computing device 200 can also include one or more output devices,such as a display 218. The display 218 may be, in one example, a touchsensitive display that combines a display with a touch sensitive elementthat is operable to sense touch inputs. The display 218 can be coupledto the CPU 202 via the bus 212. Other output devices that permit a userto program or otherwise use the computing device 200 can be provided inaddition to or as an alternative to the display 218. When the outputdevice is or includes a display, the display can be implemented invarious ways, including by a liquid crystal display (LCD), a cathode-raytube (CRT) display or light emitting diode (LED) display, such as anorganic LED (OLED) display.

The computing device 200 can also include or be in communication with animage-sensing device 220, for example a camera, or any otherimage-sensing device 220 now existing or hereafter developed that cansense an image such as the image of a user operating the computingdevice 200. The image-sensing device 220 can be positioned such that itis directed toward the user operating the computing device 200. In anexample, the position and optical axis of the image-sensing device 220can be configured such that the field of vision includes an area that isdirectly adjacent to the display 218 and from which the display 218 isvisible.

The computing device 200 can also include or be in communication with asound-sensing device 222, for example a microphone, or any othersound-sensing device now existing or hereafter developed that can sensesounds near the computing device 200. The sound-sensing device 222 canbe positioned such that it is directed toward the user operating thecomputing device 200 and can be configured to receive sounds, forexample, speech or other utterances, made by the user while the useroperates the computing device 200.

Although FIG. 2 depicts the CPU 202 and the memory 204 of the computingdevice 200 as being integrated into a single unit, other configurationscan be utilized. The operations of the CPU 202 can be distributed acrossmultiple machines (each machine having one or more of processors) thatcan be coupled directly or across a local area or other network. Thememory 204 can be distributed across multiple machines such as anetwork-based memory or memory in multiple machines performing theoperations of the computing device 200. Although depicted here as asingle bus, the bus 212 of the computing device 200 can be composed ofmultiple buses. Further, the secondary storage 214 can be directlycoupled to the other components of the computing device 200 or can beaccessed via a network and can comprise a single integrated unit such asa memory card or multiple units such as multiple memory cards. Thecomputing device 200 can thus be implemented in a wide variety ofconfigurations.

FIG. 3 is a diagram of an example of a video stream 300 to be encodedand subsequently decoded. The video stream 300 includes a video sequence302. At the next level, the video sequence 302 includes a number ofadjacent frames 304. While three frames are depicted as the adjacentframes 304, the video sequence 302 can include any number of adjacentframes 304. The adjacent frames 304 can then be further subdivided intoindividual frames, e.g., a frame 306. At the next level, the frame 306can be divided into a series of segments 308 or planes. The segments 308can be subsets of frames that permit parallel processing, for example.The segments 308 can also be subsets of frames that can separate thevideo data into separate colors. For example, the frame 306 of colorvideo data can include a luminance plane and two chrominance planes. Thesegments 308 may be sampled at different resolutions.

Whether or not the frame 306 is divided into the segments 308, the frame306 may be further subdivided into blocks 310, which can contain datacorresponding to, for example, 16×16 pixels in the frame 306. The blocks310 can also be arranged to include data from one or more segments 308of pixel data. The blocks 310 can also be of any other suitable sizesuch as 4×4 pixels, 8×8 pixels, 16×8 pixels, 8×16 pixels, 16×16 pixelsor larger.

FIG. 4 is a block diagram of an encoder 400 in accordance withimplementations of this disclosure. The encoder 400 can be implemented,as described above, in the transmitting station 102 such as by providinga computer software program stored in memory, for example, the memory204. The computer software program can include machine instructionsthat, when executed by a processor such as the CPU 202, cause thetransmitting station 102 to encode video data in manners describedherein. The encoder 400 can also be implemented as specialized hardwareincluded in, for example, the transmitting station 102. The encoder 400has the following stages to perform the various functions in a forwardpath (shown by the solid connection lines) to produce an encoded orcompressed bitstream 420 using the video stream 300 as input: anintra/inter prediction stage 402, a transform stage 404, a quantizationstage 406, and an entropy encoding stage 408. The encoder 400 may alsoinclude a reconstruction path (shown by the dotted connection lines) toreconstruct a frame for encoding of future blocks. In FIG. 4, theencoder 400 has the following stages to perform the various functions inthe reconstruction path: a dequantization stage 410, an inversetransform stage 412, a reconstruction stage 414, and a loop filteringstage 416. Other structural variations of the encoder 400 can be used toencode the video stream 300.

When the video stream 300 is presented for encoding, the frame 306 canbe processed in units of blocks. At the intra/inter prediction stage402, a block can be encoded using intra-frame prediction (also calledintra-prediction) or inter-frame prediction (also calledinter-prediction), or a combination of both. In any case, a predictionblock can be formed. In the case of intra-prediction, all or a part of aprediction block may be formed from samples in the current frame thathave been previously encoded and reconstructed. In the case ofinter-prediction, all or part of a prediction block may be formed fromsamples in one or more previously constructed reference framesdetermined using motion vectors.

Next, still referring to FIG. 4, the prediction block can be subtractedfrom the current block at the intra/inter prediction stage 402 toproduce a residual block (also called a residual). The transform stage404 transforms the residual into transform coefficients in, for example,the frequency domain using block-based transforms. Such block-basedtransforms include, for example, the DCT and the Asymmetric DST. Otherblock-based transforms are possible. Further, combinations of differenttransforms may be applied to a single residual. In one example ofapplication of a transform, the DCT transforms the residual block intothe frequency domain where the transform coefficient values are based onspatial frequency. The lowest frequency (DC) coefficient is located atthe top-left of the matrix and the highest frequency coefficient islocated at the bottom-right of the matrix. It is worth noting that thesize of a prediction block, and hence the resulting residual block, maybe different from the size of the transform block. For example, theprediction block may be split into smaller blocks to which separatetransforms are applied.

The quantization stage 406 converts the transform coefficients intodiscrete quantum values, which are referred to as quantized transformcoefficients, using a quantizer value or a quantization level. Forexample, the transform coefficients may be divided by the quantizervalue and truncated. The quantized transform coefficients are thenentropy encoded by the entropy encoding stage 408. Entropy coding may beperformed using any number of techniques, including token and binarytrees. The entropy-encoded coefficients, together with other informationused to decode the block, which may include for example the type ofprediction used, transform type, motion vectors and quantizer value, arethen output to the compressed bitstream 420. The information to decodethe block may be entropy coded into block, frame, slice and/or sectionheaders within the compressed bitstream 420. The compressed bitstream420 can also be referred to as an encoded video stream or encoded videobitstream, and the terms will be used interchangeably herein.

The reconstruction path in FIG. 4 (shown by the dotted connection lines)can be used to ensure that both the encoder 400 and a decoder 500(described below) use the same reference frames and blocks to decode thecompressed bitstream 420. The reconstruction path performs functionsthat are similar to functions that take place during the decodingprocess that are discussed in more detail below, including dequantizingthe quantized transform coefficients at the dequantization stage 410 andinverse transforming the dequantized transform coefficients at theinverse transform stage 412 to produce a derivative residual block (alsocalled a derivative residual). At the reconstruction stage 414, theprediction block that was predicted at the intra/inter prediction stage402 can be added to the derivative residual to create a reconstructedblock. The loop filtering stage 416 can be applied to the reconstructedblock to reduce distortion such as blocking artifacts.

Other variations of the encoder 400 can be used to encode the compressedbitstream 420. For example, a non-transform based encoder 400 canquantize the residual signal directly without the transform stage 404for certain blocks or frames. In another implementation, an encoder 400can have the quantization stage 406 and the dequantization stage 410combined into a single stage.

FIG. 5 is a block diagram of a decoder 500 in accordance withimplementations of this disclosure. The decoder 500 can be implementedin the receiving station 106, for example, by providing a computersoftware program stored in the memory 204. The computer software programcan include machine instructions that, when executed by a processor suchas the CPU 202, cause the receiving station 106 to decode video data inthe manners described below. The decoder 500 can also be implemented inhardware included in, for example, the transmitting station 102 or thereceiving station 106.

The decoder 500, similar to the reconstruction path of the encoder 400discussed above, includes in one example the following stages to performvarious functions to produce an output video stream 516 from thecompressed bitstream 420: an entropy decoding stage 502, adequantization stage 504, an inverse transform stage 506, anintra/inter-prediction stage 508, a reconstruction stage 510, a loopfiltering stage 512 and a post filtering stage 514. Other structuralvariations of the decoder 500 can be used to decode the compressedbitstream 420.

When the compressed bitstream 420 is presented for decoding, the dataelements within the compressed bitstream 420 can be decoded by theentropy decoding stage 502 to produce a set of quantized transformcoefficients. The dequantization stage 504 dequantizes the quantizedtransform coefficients (e.g., by multiplying the quantized transformcoefficients by the quantizer value), and the inverse transform stage506 inverse transforms the dequantized transform coefficients using theselected transform type to produce a derivative residual that can beidentical to that created by the inverse transform stage 412 in theencoder 400. Using header information decoded from the compressedbitstream 420, the decoder 500 can use the intra/inter-prediction stage508 to create the same prediction block as was created in the encoder400, e.g., at the intra/inter prediction stage 402. At thereconstruction stage 510, the prediction block can be added to thederivative residual to create a reconstructed block. The loop filteringstage 512 can be applied to the reconstructed block to reduce blockingartifacts. Other filtering can be applied to the reconstructed block. Inan example, the post filtering stage 514 is applied to the reconstructedblock to reduce blocking distortion, and the result is output as anoutput video stream 516. The output video stream 516 can also bereferred to as a decoded video stream, and the terms will be usedinterchangeably herein.

Other variations of the decoder 500 can be used to decode the compressedbitstream 420. For example, the decoder 500 can produce the output videostream 516 without the post filtering stage 514. In some implementationsof the decoder 500, the post filtering stage 514 is applied before theloop filtering stage 512. Additionally, or alternatively, the encoder400 includes a deblocking filtering stage in addition to the loopfiltering stage 416.

In the encoder 400 and the decoder 500, blocks of transform coefficientsmay be determined by transforming residual values according to atransform type. A transform type may be one or more one-dimensionaltransform types, including a one-dimensional horizontal transform type,referred to herein as TX_CLASS_HORIZ, where identity transform isapplied to columns, or a one-dimensional vertical transform type,referred to herein as TX_CLASS_VERT, where identity transform is appliedto rows. In a one-dimensional horizontal transform type, identitytransform is applied to columns. Similarly, in a one-dimensionalvertical transform type, identity transform is applied to rows. Atransform type may also be a two-dimensional transform type, referred toherein as TX_CLASS_2D. Whichever transform type is selected is used totransform the residual values into the frequency domain during encodingand to inverse-transform from the frequency domain during decoding. Aspreviously described, the transform coefficients may be quantized.

The quantized transform coefficients may be represented using level mapsand encoded or decoded using context-based arithmetic coding methods.These coding and operations are performed, for example, in the entropyencoding stage 408 of the encoder 400 and the entropy decoding stage 502of the decoder 500. Context-based arithmetic coding methods code valuesusing a probability model that is selected based on a coding context orsimply a context. The coding context includes values that are within aspatial area near the value being coded. Selecting the probability modelbased on the coding context allows for better modelling of probabilitiesgiven that a high level of correlation between coding modes is typicallypresent in a given spatial area. When coding a transform value from ablock, the context is determined based on a template. The template maybe selected based on the transform type.

In level map coding, the transform block is decomposed into multiplelevel maps such that the level maps break down (i.e., reduce) the codingof each transform coefficient value into a series of binary decisionseach corresponding to a magnitude level (i.e., a map level). Thedecomposition can be done by using a multi-run process. As such, atransform coefficient of the transform block is decomposed into a seriesof level maps, which may be level binaries, and a residue according tothe equation:

${{{coefficient}\lbrack r\rbrack}\lbrack c\rbrack} = {\{ {( {\sum\limits_{k = 0}^{T}\;{{{level}_{k}\lbrack r\rbrack}\lbrack c\rbrack}} ) + {{{residue}\lbrack r\rbrack}\lbrack c\rbrack}} \}*{{{sign}\lbrack r\rbrack}\lbrack c\rbrack}}$Where

-   -   residue [r][c]=absolute(coefficient [r][c])−T−1; and

${{{sign}\lbrack r\rbrack}\lbrack c\rbrack} = \{ {\begin{matrix}{{1\mspace{14mu}{if}\mspace{14mu}{{{coefficient}{\;\mspace{11mu}}\lbrack r\rbrack}\lbrack c\rbrack}} > 0} \\{{{{- 1}\mspace{14mu}{if}\mspace{14mu}{{{coefficient}{\;\mspace{11mu}}\lbrack r\rbrack}\lbrack c\rbrack}} < 0}\mspace{14mu}}\end{matrix}.} $

In the above equation, coefficient[r][c] is the transform coefficient ofthe transform block at the position (row=r, column=c), T is the maximummap level, level_(k) is the level map corresponding to map level k,residue is a coefficient residual map, and sign is the sign map of thetransform coefficients. The transform coefficients of a transform blockcan be re-composed using the same equation, such as by a decoder, fromencoded level_(k) maps, residual map residue, and sign map sign. Levelmap coding will be explained further with reference to FIGS. 6 and 7.

FIG. 6 is a diagram showing scan orders that can be utilized when codinga block of transform coefficients in accordance with implementations ofthis disclosure. The scan orders include a zig-zag scan order 601, ahorizontal scan order 602, and a vertical scan order 603. In theillustrated example the blocks are 4×4 blocks that each include 16values. Each has four rows, labelled R0-R3 in left-to-right order, andfour columns, labelled C0-C3 in top-to-bottom order. Individuallocations in each block correspond to individual transform coefficients,and can be addressed in the format [r, c], where r represents the rownumber and c represents the column number. Each of the zig-zag scanorder 601, the horizontal scan order 602, and the vertical scan order603 starts at position [0, 0], and the numbers shown indicate the orderin which locations in the block are visited/processed subsequent toposition [0, 0], according to the scan order. The zig-zag scan order 601visits locations in the block along diagonals, proceeding in aleft-to-right and top-to-bottom manner. The horizontal scan order 602proceeds left-to-right along each row before proceeding to the next rowin top-to-bottom order. The vertical scan order 603 proceedstop-to-bottom along each column before proceeding to the next column inleft-to-right order.

FIG. 7 is a diagram illustrating the stages of transform coefficientcoding using level maps in accordance with implementations of thisdisclosure. FIG. 7 shows a transform block 704 and level maps thatrepresent the transform block, including an end-of-block map 706, anon-zero map 708, a sign map 710, a level-1 map 712, a level-2 map 714,and a coefficient residue or residual map 716.

The transform block 704 is an example of a block of transformcoefficients that can be received from the quantization step of anencoder, such as the quantization stage 406 of the encoder 400 of FIG.4. The transform block 704 includes zero and non-zero transformcoefficients. Some of the non-zero coefficients may be negative values.

The end-of-block map 706 indicates the end-of-block position for thetransform block 704. The end-of-block position is the position at whichthere are no further non-zero values in the transform block 704, asdetermined when the transform coefficient positions are visited in thescan order being used. Thus, at and after the end-of-block position, allvalues are from the transform block 704 are zero. In the illustratedexample, the zig-zag scan order 601 is used, non-zero coefficients thatare other than the end-of-block position are indicated with a value ofzero, and the end-of-block position is indicated with a value of one(1). In the illustrated example, the end-of-block is located at position[2, 2] as indicated by the value one (1) at that position, withpreceding non-zero values indicated by the value zero.

The non-zero map 708 is a level map that indicates, for each position inthe transform block 704, whether the corresponding transform coefficientis equal to zero or is a non-zero value. In the illustrated example, thenon-zero map 708 includes a zero at the location of each transformcoefficient that has a zero value and is located before the end-of-blockposition, and the non-zero map 708 includes the value one (1) at alllocations that have a non-zero value in the transform block 704. Thenon-zero map 708 may also be referred to as a level-zero map.

The sign map 710 indicates, for each position of the transform block 704that has a non-zero value, whether the corresponding transformcoefficient has a positive value or a negative value. In the illustratedexample, the value −1 indicates that the corresponding transformcoefficient has a negative value, and the value one indicates that thecorresponding transform coefficient has a positive value. Other symbolscan be utilized, such as zero and one.

The non-zero map 708, the level-1 map 712, the level-2 map 714, and thecoefficient residual map 716, in combination, define the absolute valuefor the transform coefficients from the transform block 704. Of these,the non-zero map 708, the level-1 map 712, the level-2 map indicate,using only binary values, whether the corresponding transformcoefficients from the transform block 704 have an absolute value that isequal to zero, one, or two, or is greater than or equal to three. Foreach non-zero value, as indicated by the non-zero map 708, the level-1map 712 includes the value zero if the absolute value of thecorresponding transform coefficient is equal to one, or includes thevalue one if the absolute value of the transform coefficient is greaterthan or equal to two. For each value indicated as greater than or equalto two in the level-1 map 712, the level-2 map 714 includes the valuezero if the absolute value of the corresponding transform coefficient isequal to two, or includes the value one if the absolute value of thetransform coefficient is greater than or equal to three.

In one alternative example, a single level map can replace the non-zeromap 708, the level-1 map 712, and the level-2 map, by using a two bitvalue to indicate, for each transform coefficient from the transformblock 704, whether the absolute value of the transform coefficient isequal to zero, one, or two, or is greater than or equal to three. Inanother alternative example, a different number of level maps can beused, in which case the threshold at which a residual value is presentwill change.

In the illustrated example, the coefficient residual map 716 includesthe residue for each transform coefficient from the transform block 704.The residue for each transform coefficient from the transform block 704is the magnitude of the transform coefficient in excess of therepresentation of the magnitude in the level maps. In this example,residue for each transform coefficient from the transform block 704 iscalculated as the absolute value of the transform coefficient from thetransform block 704 minus three.

FIG. 8 is a flowchart diagram of a process 800 for encoding a transformblock in an encoded video bitstream using level maps according to animplementation of this disclosure. The process 800 can be implemented inan encoder such as the encoder 400. The encoded video bitstream can bethe compressed bitstream 420 of FIG. 4.

The process 800 can be implemented, for example, as a software programthat can be executed by computing devices such as transmitting station102. The software program can include machine-readable instructions thatcan be stored in a memory such as the memory 204 or the secondarystorage 214, and that can be executed by a processor, such as CPU 202,to cause the computing device to perform the process 800. In at leastsome implementations, the process 800 can be performed in whole or inpart by the entropy encoding stage 408 of the encoder 400.

The process 800 can be implemented using specialized hardware orfirmware. Some computing devices can have multiple memories, multipleprocessors, or both. The steps or operations of the process 800 can bedistributed using different processors, memories, or both. Use of theterms “processor” or “memory” in the singular encompasses computingdevices that have one processor or one memory as well as devices thathave multiple processors or multiple memories that can be used in theperformance of some or all of the recited steps.

The process 800 can receive a transform block, such as the transformblock 704 of FIG. 7. The transform block 704 can be received as theoutput from the quantization step of an encoder, such as thequantization stage 406 of the encoder 400 of FIG. 4. The transform block704 includes zero and non-zero transform coefficients. Some of thenon-zero coefficients may be negative values.

In operation 801, the end-of-block position (EOB) is encoded bygenerating and including values in the encoded video bitstream thatindicate the end-of-block position. In an implementation of the process800, operation 802 can include generating an end-of-block map for thetransform block, as explained with respect to the end-of-block map 706.At and after EOB, all coefficients are zeroes.

In operation 802, a value BL[i] is coded to indicate the magnitude ofthe transform coefficient, where i denotes the scan position (i=0corresponds to the top-left position, which is commonly referred to asthe DC position), and BL[i] denotes whether the magnitude of thequantized coefficient at scan position i is 0, 1, 2, or ≥3. The valueBL[i] is coded (e.g., 0, 1, 2, or 3) for each position in the scan orderin reverse order from the position before the end-of-block position(i=EOB−1) to the DC position (i=0). In some implementations, the valueBL[i] is coded in operation 802 using level maps, such as the non-zeromap 708, the level-1 map 712, and the level-2 map 714.

The value BL[i] is coded into the video bitstream in operation 802 usingcontext-based arithmetic coding methods. Context-based arithmetic codingmethods utilize a context model, which can be determined based on thebinary values of any number of previously coded neighbors, and can fullyutilize information from all these neighbors. The previously codedneighbors can be neighbors in the same level map or a preceding levelmap, such as an immediately preceding level map. For example, thelevel-1 map 712 can provide context information for coding the level-2map 714.

In some implementations of the process 800, operation 801 and operation802 are combined by interleaving the end-of-block map 706 into thenon-zero map 708.

In operation 803, a residual value, referred to as BR[i], is coded forall transform coefficients that have an absolute value for its magnitudegreater than what is represented by the value BL[i], which in thepresent example represents quantized transform coefficients having anabsolute value of 0, 1, and 2 without use of a residual value. Thus, inthis example, for each quantized transform coefficient having anabsolute value for its magnitude greater than two (e.g., BL(i)=3), thevalue BR[i] denotes the magnitude of the quantized transform coefficientat scan position i, and is equal to the magnitude value of the quantizedtransform coefficient for scan position i minus three.

Like the values BL[i], the residual values BR[i] can be coded into thevideo bitstream in operation 803 using context-based arithmetic codingmethods. Context-based arithmetic coding methods utilize a contextmodel, which can be determined based on the binary values of any numberof previously coded neighbors, and can fully utilize information fromall these neighbors. The previously coded neighbors can be neighbors inthe same level map or a preceding level map, such as an immediatelypreceding level map. The residual values BR[i] can be encoded in theencoded video bitstream using binary coding or multi-symbol coding. Aprobability distribution that fits the statistics of the residualcoefficients of the coefficients residue map can be used. Theprobability distribution can be a geometric distribution, a Laplaciandistribution, a Pareto distribution, or any other distribution.

In operation 804, a value is coded for each non-zero quantized transformcoefficient indicating whether the sign of the quantized transformcoefficient is positive or negative. This value may be referred to asSign[i], where i denotes the scan position and Sign[i] denotes the signof the non-zero coefficient at scan position i. Operation 804 may beperformed using the sign map 710. Coding Sign[i] may be performed usingcontext-based or non-context-based entropy coding techniques.

In some implementations, the available values for BR(i) may include amaximum value. In an example, BR(i) may take any of the values from 0 to12 when BL(i) is equal to 3. Together with BL(i), this corresponds toabsolute values for the magnitude L(i) of the quantized transformcoefficient at scan position i of 0 through 15. A value of 12 for BL(i)can indicate that the residual value is greater than or equal to 15. Ifapplicable (i.e., BR(i) has a maximum value and the magnitude L(i) ofthe quantized transform coefficient is greater than or equal to 15), themagnitude of the quantized transform coefficient minus 15 (L(i)−15) iscoded in operation 805. The magnitudes can be encoded in the encodedvideo bitstream using binary coding or multi-symbol coding. Aprobability distribution that fits the statistics of the residualcoefficients of the coefficients residue map can be used. Theprobability distribution can be a geometric distribution, a Laplaciandistribution, a Pareto distribution, or any other distribution. Codingthe resulting symbols may not require any context derivation. That is,the symbols may not be context-coded.

In some embodiments, coding of BL and BR symbols may have its own loopfor the current block followed by another loop for coding of applicablesigns and the magnitude of the quantized transform coefficient minus 15in the same block.

The quantized transform coefficients may be reconstructed using thecoded values to verify the encoding after operation 805.

In the process 800, spatial neighboring templates can be utilized fordetermining context models used in context-based arithmetic codingmethods. For example, in operation 802, the context used to code thevalue BL[i] is derived by using a spatial template anchored to the blockposition (r_i, c_i) corresponding to the scan position i, where r_idenotes the row index and c_i denotes the column index.

FIG. 9A is a diagram showing a first set of spatial neighboringtemplates that can be utilized in context-based arithmetic codingmethods in accordance with implementations of this disclosure. Ahorizontal template 901 includes multiple context neighbors that are inthe same row as the position of a transform coefficient to be coded(i.e., a transform coefficient to be encoded or decoded that may bereferred to herein as a position to be coded for brevity), and onecontext neighbor in the same column as the position to be coded. In theillustrated example, the horizontal template 901 includes four contextneighbors to the right of the position to be coded and one contextneighbor below the position to be coded. A vertical template 902includes one context neighbor that is in the same row as the position tobe coded, and multiple context neighbors in the same column as theposition to be coded. In the illustrated example, the vertical template902 includes one context neighbor to the right of the position to becoded and four context neighbors below the position to be coded. Atwo-dimensional template 903 includes context neighbors in a triangularpattern that is anchored at the position to be coded. In the illustratedexample, the two-dimensional template 903 includes two context neighborsto the right of the position to be coded, two context neighbors belowthe position to be coded, and one context neighbor that is locateddiagonally downward and rightward relative to the position to be coded.

The first set of spatial neighboring templates illustrated in FIG. 9Amay be used to derive contexts for BL[i]. The same or a different set ofspatial neighboring templates may be used to derive contexts for BR[i].FIG. 9B is a diagram showing a second set of spatial neighboringtemplates that can be utilized in context-based arithmetic codingmethods in accordance with implementations of this disclosure. Forexample, the second set of spatial neighboring templates may be used toderive contexts for BR[i].

In the second set of spatial neighboring templates, a horizontaltemplate 905 includes multiple context neighbors that are in the samerow as a position to be coded, and one context neighbor in the samecolumn as the position to be coded. In the illustrated example, thehorizontal template 905 includes two context neighbors to the right ofthe position to be coded and one context neighbor below the position tobe coded. A vertical template 906 includes one context neighbor that isin the same row as the position to be coded, and multiple contextneighbors in the same column as the position to be coded. In theillustrated example, the vertical template 906 includes one contextneighbor to the right of the position to be coded and two contextneighbors below the position to be coded. A two-dimensional template 907includes context neighbors in a triangular pattern that is anchored atthe position to be coded. In the illustrated example, thetwo-dimensional template 907 includes one context neighbor to the rightof the position to be coded, one context neighbor below the position tobe coded, and one context neighbor that is located diagonally downwardand rightward relative to the position to be coded.

The spatial neighboring template that is used in a specific codingoperation may be selected based on the transform type used to determinethe quantized transform coefficients. For example, if the transform typeis a one-dimensional horizontal transform (TX_CLASS_HORIZ) type, thehorizontal template 901 and/or the horizontal template 905 may be used.If the transform type is a one-dimensional vertical transform type(TX_CLASS_VERT), the vertical template 902 and/or the vertical template906 may be used. If the transform type is a two-dimensional transformtype (TX_CLASS_2D), the two-dimensional template 903 and/or thetwo-dimensional template 907 may be used.

During context-based coding, obtaining the values to be used in theselected template as context neighbors may become costly in a naiveimplementation, such as one that obtains the needed values by a tablelookup. That is, for example, there are three transform type classes,each of which has its own templates, a straightforward implementationmay need at least three arrays to store the neighborhood positions foreach valid transform size. A practical implementation is furthercomplicated where the codec specifies a number of scan orders. In thissituations, the arrays may need to be defined based on block positionsinstead of scan positions to avoid being scan order dependent.Accordingly, table lookups can result in performance issues, such asmemory bottlenecks. Performance issues may be more common, for example,when the block size is large (e.g., a 32×32 transform block, which has1024 positions).

According to implementations of this disclosure, performance can beimproved by storing needed information in memory registers arrays, orsimply register arrays. To allow use of register arrays for thispurpose, the scan orders used for coding of transform coefficients, suchas the zig-zag scan order 601, the horizontal scan order 602, and thevertical scan order 603, share common properties in that thecoefficients in a row are visited from left to right and coefficients ina column are visited from top to bottom in the scan order. Statedanother way, given a scan order S, iS[r, c] denotes the scan positionfor a valid block position [r, c], where r denotes the row index and cdenotes the column index in a transform block. Then iS[r, c]<iS[r′, c]for any r′>r and iS[r, c]<iS[r, c′] for any c′>c. Thus, during coding oflevel maps, when coded in reverse scan order, the context neighborsneeded for coding a current value to be coded have already been visited.

In the implementations that will be described herein, information neededfor context derivation is stored sets of registers, for example, inregister sets comprising two or three register arrays, as showninitially the example of FIGS. 10-12. FIG. 10 is a diagram that shows afirst example of a register set that corresponds to a horizontaltemplate. FIG. 11 is a diagram that shows a first example of a registerset that corresponds to a vertical template. FIG. 12 is a diagram thatshows a first example of a register set that corresponds to atwo-dimensional template. The example of FIGS. 10-12 uses the first setof spatial neighboring templates of FIG. 9A to derive the contexts forbase level symbols (i.e., BL[i]).

By using a limited set of memory or register arrays, context informationfor all positions of the transform block need not be held in memory. Theregister sets implement template-based coding by holding values forlocations in the template being used, such as the horizontal template901, the vertical template 902, and the two-dimensional template 903 inthis example. Thus, the register sets can correspond to the size andshape of the template being used, with each register value correspondingto a particular spatial location (e.g., a context neighbor) in thetemplate. Accordingly, a value within a register array may be referredto herein as a context neighbor value. In some implementations, theregister sets include at least a first register array that has a firstsize (e.g., for storing a first number of values) and a second registerarray that has a second size (e.g., for storing a second number ofvalues) that is different than the first size.

The values in the register arrays of a register set are initially set toa default value (e.g., zero). Whenever a position [r, c] is out of blockboundary, a default value such as 0 may be used at the position. Once avalue is coded (e.g., a symbol is encoded or decoded), the registerarrays are updated for use in coding the next value, using the value ofthe position that was coded and/or base information obtained from thelevel maps.

For a transform of size M×N in TX_CLASS_HORIZ, the number of registerarrays in a register set is equal to the number of rows N. In thisimplementation, a register set includes one 8-bit register array and one2-bit register array, which hold values corresponding to the horizontaltemplate 901 on a per-row basis. The register set is used for coding aparticular value in a row of the transform block. For a transform ofsize M×N in TX_CLASS_VERT, the number of register arrays in a registerset is equal to the number of columns M. In this implementation, aregister set includes one 8-bit register array and one 2-bit registerarray, which hold values corresponding to the vertical template 902 on aper-column basis. The register set is used for coding a particular valuein a column of the transform block. For a transform of size M×N inTX_CLASS_2D, the number of register arrays in a register set is equal tothe lower of the number of columns M and the number of rows N. In thisimplementation, a register set includes two 4-bit register arrays andone 2-bit register array, which hold values corresponding to thetwo-dimensional template 903. Thus, context neighbor values are storedin the register set for the context neighbors defined by the shape ofthe two-dimensional template 903, on either of a per-column or per-rowbasis (dependent on the smaller dimension of the transform), and aregister set is used for coding a particular value in a column or row ofthe transform block. The register sets described above all store valuesusing 2-bit precision (e.g., an 8-bit register stores four 2-bit valuesand a 2-bit register stores one 2-bit value). It should be understood,however, that values of differing precisions could be utilized. Itshould further be understood that the number of values held in eachregister array can be changed according to the geometry of a particularspatial template.

For coding a transform block determined using TX_CLASS_HORIZ and acontext corresponding to the horizontal template 901, there are Nregister arrays, corresponding to rows r=0 through N−1. FIG. 10 is adiagram that shows an example of a register set that corresponds to thehorizontal template 901. Each register set includes two register arrays,including a first register array S0 and a second register array S1,which are defined respectively as:

-   -   S0[r, 0], S0[r, 1], S0[r, 2], S0[r, 3], and    -   S1[r, 0].

As shown in FIG. 10, the register array S0 stores values for the samerow and to the right of a scan position i of one or more values for thetransform coefficient being coded that indicates the magnitude of thetransform coefficient, and the register array S1 stores a single valuein the same column and one row below the scan position i of the one ormore values for the transform coefficient being coded that indicates themagnitude of the transform coefficient. The scan position i is labeledBL[i] here and in FIGS. 11-15 discussed below because it is the valueBL[i] for the transform coefficient at the scan position i that is beingcoded (i.e., either encoded or decoded) in these examples. Accordingly,the scan position i may be referred to as the position of the valueBL[i] being coded herein.

For coding a transform block determined using TX_CLASS_VERT and acontext corresponding to the vertical template 902, there are M registerarrays, corresponding to columns c=0 through M−1. FIG. 11 is a diagramthat shows an example of a register set that corresponds to the verticaltemplate 902. Each register set includes two register arrays, includinga first register array S0 and a second register array S1, which aredefined respectively as:

-   -   S0[c, 0], S0[c, 1], S0[c, 2], S0[c, 3], and    -   S1[c, 0].        As shown in FIG. 11, the register array S0 stores values for the        same column and below the position of the value BL[i] being        coded, and the register array S1 stores a single value in the        same row and one row to the right of the position of the value        BL[i] being coded.

For coding a transform block determined using TX_CLASS_2D, withreference to an example in which the transform block has fewer columns Mthan rows N (i.e., M<N), and using a context corresponding to thetwo-dimensional template 903, there are M register arrays, correspondingto columns c=0 through M−1. FIG. 12 is a diagram that shows an exampleof a register set that corresponds to the two-dimensional template 903.Each register set includes three registers arrays, including a firstregister array S0, a second register array S1, and a third registerarray S3, which are defined respectively as:

-   -   S0[c, 0], S0[c, 1],    -   S1[c, 0], S1[c, 1], and    -   S2[c, 0].

As shown in FIG. 12, the register array S0 stores values for the samecolumn as the position of the value BL[i] being coded, the registerarray S1 stores values one column to the right of the position of thevalue BL[i] being coded, and the register array S2 stores a single valuelocated two columns to the right of the position of the value BL[i]being coded. In some implementations, each register set is organizedinto three arrays, where in the first array (for S0) has size 2 (i.e.,stores two coefficient neighbor values), the second array (for S1) hassize 2 (i.e., stores two coefficient neighbor values), and the thirdarray (for S2) has size 1 (i.e., stores one coefficient neighbor value).

At the beginning of coding a transform block, the register set isdefined according to the transform type that was used to determine thetransform coefficients for the transform block, and all of the values ina register set are initialized to zero. The value BL[i] to be coded atscan position i, where BL[i] is from {0, 1, 2, 3}, is assigned a blockposition corresponding to the scan position i denoted by row r_i andcolumn c_i. When encoding, the value BL[i] is obtained from baseinformation, such as the level maps. In decoding, the input is theportion of the encoded bitstream from which the value BL[i] is derived.The context to entropy code the value BL[i] is determined by combining(e.g., summing) the values from the register arrays, which represent thespatial context neighbors of the value BL[i] according to the templatethat corresponds to the transform type.

If the transform type is one in TX_CLASS_HORIZ, the context used to codethe value BL[i] is derived from:

-   -   S0[r_i, 0]+S0[r_i, 1]+S0[r_i, 2]+S0[r_i, 3]+S1[r_i, 0].        After the value BL[i] is coded, the register array values are        updated as follows:    -   S0[r_i, 0]=BL[i],    -   S0[r_i, 1]=S0[r_i, 0],    -   S0[r_i, 2]=S0[r_i, 1],    -   S0[r_i, 3]=S0[r_i, 2], and    -   S1[r_i, 0]=BL[iS[r_i+1, c_i−1]].        To summarize the foregoing, the values in a register array are        updated to assume the values of their immediate neighbors, which        in this case are values of the positions to the immediate left        of the locations represented by each of the values in the        register array. For register array S0, the first value S0[r_1,        0] is updated to the value at the position that was just coded        BL[i]. The remaining values in register array S0 assume the        values from the preceding value in the register array (i.e.,        values in the register array are shifted by one position). For        the register array S1, the sole value is updated using base        information obtained from the level maps, namely the value to be        coded for the cell located one row below and one column to the        left of the position of the value BL[i] that was just coded,        which is labeled with as value BL[iS[r_i+1, c_i−1]]. After        updating, this register set is ready for use in coding the next        value in the same row (i.e., the value in the position directly        to the left of the position of the value BL[i] that was just        coded).

If the transform type is one in TX_CLASS_VERT, the context used to codethe value BL[i] is derived from

-   -   S0[c_i, 0]+S0[c_i, 1]+S0[c_i, 2]+S0[c_i, 3]+S1[c_i, 0].        After the value BL[i] is coded, the register arrays are updated        as follows:    -   S0[c_i, 0]=BL[i],    -   S0[c_i, 1]=S0[c_i, 0],    -   S0[c_i, 2]=S0[c_i, 1],    -   S0[c_i, 3]=S0[c_i, 2], and    -   S1[c_i, 0]=BL[iS[r_i−1, c_i+1]].        To summarize the foregoing, the values in the register arrays        are updated to assume the values of their immediate neighbors,        which in this case are values of the positions immediately above        the locations represented by each of the values in the register        array. For register array S0, the first value S0[c_i, 0] is        updated to the value BL[i] that was just coded. The remaining        values in the register array S0 assume the values from the        preceding value in the register array (i.e., values in the        register array are shifted by one position). For register array        S1, the sole value is updated using base information obtained        from the level maps, namely the value to be coded for the cell        located one row above and one column to the right of the        position of the value BL[i] that was just coded, which is value        BL[iS[r_i−1, c_i+1]]. After updating, this register set is ready        for use in coding the next value in the same column (i.e., the        value in the position directly above the position of the value        BL[i] that was just coded).

If the transform type is one in TX_CLASS_2D, continuing the example inwhich the transform block has fewer columns M than rows N (i.e., M<N),the context used to code the value BL[i] is derived by:

-   -   S0[c_i, 0]+S0[c_i, 1]+S1[c_i, 0]+S1[c_i, 1]+S2[c_i, 0].        After the value BL[i] is coded, the register arrays are updated        as follows.    -   S0[c_i, 0]=BL[i],    -   S0[c_i, 1]=S0[c_i, 0],    -   S1[c_i, 0]=BL[iS[r_i−1, c_i+1]],    -   S1[c_i, 1]=S1[c_i, 0], and    -   S2[c_i, 0]=BL[iS[r_i−1, c_i+2]].        To summarize the foregoing, the values in the register arrays        are updated to assume the values of their immediate neighbors,        which in this case are values of the positions immediately above        the locations represented by each of the values in the register        arrays. For the register array S0, the first value S0[c_i, 0] is        updated to the value that was just coded BL[i], and the second        value in register array S0, denoted by S0[c_i, 1], assumes the        value from the preceding value in the register array (i.e.,        values in the register array are shifted by one position), which        in this example is the value S0[c_i, 0]. For the second register        array S1, the first value is updated using base information        obtained from the level maps, namely the value to be coded for        the cell located one row above and one column to the right of        the position of the value BL[i] that was just coded, which is        value BL[iS[r_i−1, c_i+1]], and the second value assumes the        value from the first value of the second register array S1[c_i,        0]. For the third register array S2, the sole value is updated        using base information obtained from the level maps, namely the        value to be coded for the cell located one row above and two        columns to the right of the position of the value BL[i] that was        just coded, which is value BL[iS[r_i−1, c_i+2]]. After updating,        this register set is ready for use in coding the next value in        the same column (i.e., the value in the position directly above        the position of the value BL[i] that was just coded). In an        example in which there are fewer rows than columns, the register        arrays can instead be defined on a per-row basis, with each        register set being used to provide context for coding values in        a row.

When the base range symbols (i.e., BR[i]) are context-encoded, thecontexts may be derived similarly to the contexts for base level symbolsas described above with regard to FIGS. 10-12. Alternatively, thecontexts may be derived using different templates, such as those shownin FIG. 9B, and register arrays appropriate to the number and locationsof the context neighbors. Like the register set described above withrespect to FIGS. 10-12, a first group of register values (e.g., aregister array) is updated using only information obtained from theregister set, and a second group of register values (e.g., a registerarray) is updated using base information obtained from, for example, thelevel maps. This implementation reduces reliance on base information,which can increase efficiency and avoid performance issues such asmemory bottlenecks while accurately modelling the context for each valuebeing coded.

A second example in which information needed for context derivation isstored in register sets is shown in FIGS. 13-15. FIG. 13 is a diagramthat shows a second example of a register set that corresponds to ahorizontal template. FIG. 14 is a diagram that shows a second example ofa register set that corresponds to a vertical template. FIG. 15 is adiagram that shows a second example of a register set that correspondsto a two-dimensional template. In FIGS. 13-15, the first set oftemplates of FIG. 9A are used as an example. This implementation avoidsaccessing previously coded base information, other than the value BL[i]being coded, to update register arrays after the value BL[i] is coded.Instead, the values that are not obtained by shifting of other valuesthrough the register arrays are based on the value BL[i]. Thisimplementation may be preferable in cases where accessing the baseinformation is costly.

For a transform of size M×N in TX_CLASS_HORIZ, one 8-bit register arraymay be defined to hold four 2-bit values for each row and one 2-bitregister array may be defined to hold one 2-bit value for each column tohold values that correspond spatially to the horizontal template 901,with the values to the right of the value being coded stored on aper-row basis, and the value below the value being coded stored on aper-column basis. For a transform of size M×N in TX_CLASS_VERT, one8-bit register array may be defined to hold four 2-bit values for eachcolumn and one 2-bit register array may be defined to hold one 2-bitvalue for each row, with these register arrays holding values thatcorrespond spatially to the vertical template 902, with the values belowthe value being coded stored on a per-column basis, and the value to theright of the value being coded stored on a per-row basis. For atransform of size M×N in TX_CLASS_2D, one 4-bit register array may bedefined to hold two 2-bit values for each row, one 4-bit register arraymay be defined to hold two 2-bit values for each column, and one 2-bitregister array may be defined to hold one 2-bit value for each diagonalto hold values that correspond spatially to the two-dimensional template903, with the values to the right of the value being coded stored on aper-row basis, the values below the value being coded stored on aper-column basis, and the value diagonally below and to the right of thevalue being coded stored on a per-diagonal basis. The foregoing examplesutilize registers that have 2 bits of precision for each value. Itshould be understood, however, that values of differing precisions couldbe utilized. It should further be understood that the number of valuesheld in each register can be changed according to the geometry of aparticular spatial template.

For coding a transform block of size M×N determined using TX_CLASS_HORIZusing a context corresponding to the horizontal template 901, a firstregister array S0 is defined for each row (i.e., for r=0, 1, . . . ,N−1), and a second register array S1 is defined for each column (i.e.,for c=0, 1, . . . , M−1). The first register array S0 and the secondregister array S1 are defined respectively as:

-   -   S0[r, 0], S0[r, 1], S0[r, 2], S0[r, 3] for r=0, 1, . . . , N−1,        and    -   S1[c, 0] for c=0, 1, . . . , M−1.        As shown in FIG. 13, the register array S0 includes values for        the same row and to the right of the position of the value BL[i]        being coded, and the register array S1 includes a single value        in the same column and one row below the position of the value        BL[i] being coded.

For coding a transform block of size M×N determined using TX_CLASS_VERTand a context corresponding to the vertical template 902, a firstregister array S0 is defined for each column (i.e., for c=0, 1, . . . ,M−1), and a second register array S1 is defined for each row (i.e., forr=0, 1, . . . , N−1). The first register array S0 and the secondregister array S1 are defined respectively as:

-   -   S0[c, 0], S0[c, 1], S0[c, 2], S0[c, 3] for c=0, 1, . . . , M−1,        and    -   S1[r, 0] for r=0, 1, . . . , N−1.        As shown in FIG. 14, the register array S0 includes values for        the same column and below the position of the value BL[i] being        coded, and the register array S1 includes a single value in the        same row and one column to the right of the position of the        value BL[i] being coded.

For coding a transform block of size M×N determined using TX_CLASS_2Dand a context corresponding to the two-dimensional template 903, a firstregister array S0 is defined for each column (i.e., for c=0, 1, . . . ,M−1), a second register array S1 is defined for each row (i.e., for r=0,1, . . . , N−1), and a third register array S2 is defined for eachdiagonal. The first register array S0, the second register array S1, andthe third register array S2 are defined respectively as:

-   -   S0[c, 0], S0[c, 1] for c=0, 1, . . . , M−1,    -   S1[r, 0], S1[r, 1] for r=0, 1, . . . , N−1, and    -   S2[d, 0] for d=0, 1, . . . , M+N−2.        In the foregoing definition of the third register array S2, d is        the index of the diagonal line, and can be determined based on        the row index [r] and the column index [c] as follows:    -   d=0 if (r==c), and    -   d=2*abs(r−c)+(r<c) if (r!=c).

In defining the index d, the code (r<c) evaluates to zero when r<c isfalse and to one when r<c is true. Note that any bijective mapping of(r−c) to {0, 1, . . . , M+N−2} can be used to define the index d. Incases where negative indices are allowed, r-c or c-r can be useddirectly as definition of the index d. As shown in FIG. 15, the firstregister array S0 includes values for the same column and below theposition of the value BL[i] being coded, the second register array S1includes values for the same row and to the right of the position of thevalue BL[i] being coded, and the third register array S2 includes asingle value diagonally below and to the right of the position of thevalue BL[i] being coded.

At the beginning of coding a transform block, the register sets aredefined according to the transform type that was used to determine thetransform coefficients for the transform block, and all of the values inthe register arrays are initialized to zero. The value BL[i] being codedis for scan position i, where the value BL[i] is an integer from {0, 1,2, 3}. The block position corresponding to the scan position i isdenoted by row r_i and column c_i, as with the earlier examples. Inencoding, the value BL[i] is obtained from base information, such as thelevel maps. In decoding, the value BL[i] is derived from a portion ofthe encoded bitstream using the context. The context to code the valueBL[i] is determined by summing the values from the register arrays,which represent the spatial context neighbors of the value BL[i]according to the template that corresponds to the transform type.

Referring to FIG. 13, if the transform type is one in TX_CLASS_HORIZ,the context used to code the value BL[i] is derived from:

-   -   S0[r_i, 0]+S0[r_i, 1]+S0[r_i, 2]+S0[r_i, 3]+S1[c_i, 0].        After the value BL[i] is coded, the register arrays are updated        as follows:    -   S0[r_i, 0]=BL[i],    -   S0[r_i, 1]=S0[r_i, 0],    -   S0[r_i, 2]=S0[r_i, 1],    -   S0[r_i, 3]=S0[r_i, 2], and    -   S1[c_i, 0]=BL[i].        For the register array S0, the first value S0[r_1, 0] is updated        to the value BL[i] that was just coded. The remaining values in        the register array S0 assume the values from the preceding value        in the register array (i.e., values in the register array are        shifted by one position). For the register array S1, the sole        value is updated to the value BL[i] that was just coded.

Referring to FIG. 14, if the transform type is one in TX_CLASS_VERT, thecontext used to code the value BL[i] is derived from:

-   -   S0[c_i, 0]+S0[c_i, 1]+S0[c_i, 2]+S0[c_i, 3]+S1[r_i, 0].        After the value BL[i] is coded, the register arrays are updated        as follows.    -   S0[c_i, 0]=BL[i],    -   S0[c_i, 1]=S0[c_i, 0],    -   S0[c_i, 2]=S0[c_i, 1],    -   S0[c_i, 3]=S0[c_i, 2], and    -   S1[r_i, 0]=BL[i].        For the register array S0, the first value S0[c_i, 0] is updated        to the value BL[i] that was just coded. The remaining values in        the register array S0 assume the values from the preceding value        in the register array (i.e., values in the register array are        shifted by one position). In other words, the register array S0        is updated in a first-in-first-out (FIFO) manner by shifting out        the oldest value and adding the value BL[i] as the newest entry.        For the register array S1, the sole value is updated to the        value BL[i] that was just coded.

If the transform type is one in TX_CLASS_2D, the context used to codethe value BL[i] is derived from:

-   -   S0[c_i, 0]+S0[c_i, 1]+S1[r_i, 0]+S1[r_i, 1]+S2[d_i, 0].        After the value BL[i] is coded, the register arrays are updated        as follows.    -   S0[c_i, 0]=BL[i],    -   S0[c_i, 1]=S0[c_i, 0],    -   S1[r_i, 0]=BL[i],    -   S1[r_i, 1]=S1[r_i, 0], and    -   S2[d_i, 0]=BL[i], where    -   d_i=0 if (r_i==c_i), and    -   d_i=2*abs(r_i−c_i)+(r_i<c_i) if (r_i!=c_i).        In defining the index d, the code (r_i<c_i) evaluates to zero        when r_i<c_i is false and to one when r_i<c_i is true.

For the first register array S0, the first value S0[c_i, 0] is updatedto the value BL[i] that was just coded, and the second value S0[c_i, 1]is updated to the prior value of the first value in the register array(i.e., the value is shifted). For the second register array S1, thefirst value S1[r_i, 0] is updated to the value BL[i] that was justcoded, and the second value S1[r_i, 1] is updated to the prior value ofthe first value in the register array (i.e., the value is shifted). Forthe register array S2, the sole value is updated to the value BL[i] thatwas just coded BL.

A third example in which information needed for context derivation isstored in register sets is shown in FIGS. 16-18. FIG. 16 is a diagramthat shows a third example of a register set that corresponds to ahorizontal template. FIG. 17 is a diagram that shows a third example ofa register set that corresponds to a vertical template. FIG. 18 is adiagram that shows a third example of a register set that corresponds toa two-dimensional template. The example of FIGS. 16-18 uses the secondset of spatial neighboring templates of FIG. 9B to derive the contextsfor range level symbols (i.e., BR[i]). This implementation avoidsaccessing previously coded base information, other than the value BR[i]being coded, to update a register set after the value BR[i] is coded.Instead, the values that are not obtained by shifting of other valuesthrough the register arrays are based on the value BR[i]. Thisimplementation may be preferable in cases where accessing the baseinformation is costly.

For a transform of size M×N in TX_CLASS_HORIZ, one 8-bit register arraymay be defined to hold two 4-bit values for each row and one 4-bitregister array may defined to hold one 4-bit value for each column tohold values that correspond spatially to the horizontal template 905,with the values to the right of the value being coded stored on aper-row basis, and the value below the value being coded stored on aper-column basis. For a transform of size M×N in TX_CLASS_VERT, one8-bit register array may be defined to hold two 4-bit values for eachcolumn and one 4-bit register array may be defined to hold one 4-bitvalue for each row, with these register arrays holding values thatcorrespond spatially to the vertical template 906, with the values belowthe value being coded stored on a per-column basis, and the value to theright of the value being coded stored on a per-row basis. For atransform of size M×N in TX_CLASS_2D, one 4-bit register array may bedefined to hold one 4-bit value for each row, one 4-bit register arraymay be defined to hold one 4-bit value for each column, and one 4-bitregister array is defined to hold one 4-bit value for each diagonal tohold values that correspond spatially to the two-dimensional template907, with the values to the right of the value being coded stored on aper-row basis, the values below the value being coded stored on aper-column basis, and the value diagonally below and to the right of thevalue being coded stored on a per-diagonal basis. The foregoing examplesutilize register arrays that have 4 bits of precision for each value. Itshould be understood, however, that values of differing precisions couldbe utilized. It should further be understood that the number of valuesheld in each register array can be changed according to the geometry ofa particular spatial template.

For coding a transform block of size M×N determined using TX_CLASS_HORIZand a context corresponding to the horizontal template 905, a firstregister array S0 is defined for each row (i.e., for r=0, 1, . . . ,N−1), and a second register array S1 is defined for each column (i.e.,for c=0, 1, . . . , M−1). The first register array S0 and the secondregister array S1 are defined respectively as:

-   -   S0[r, 0], S0[r, 1] for r=0, 1, . . . , N−1, and    -   S1[c, 0] for c=0, 1, . . . , M−1.        As shown in FIG. 16, the register array S0 includes values for        the same row and to the right of a scan position i of one or        more values for the transform coefficient being coded that        indicates the magnitude of the transform coefficient, and the        register array S1 includes a single value in the same column and        one row below the scan position i of the one or more values for        the transform coefficient being coded that indicates the        magnitude of the transform coefficient. The scan position i is        labeled BR[i] here and in FIGS. 17 and 18 because it is the        value BR[i] for the transform coefficient at the scan position i        that is being coded (i.e., either encoded or decoded) in these        examples. Accordingly, the scan position i may be referred to as        the position of the value BR[i] being coded herein.

For coding a transform block of size M×N determined using TX_CLASS_VERTand a context corresponding to the vertical template 906, a firstregister array S0 is defined for each column (i.e., for c=0, 1, . . . ,M−1), and a second register array S1 is defined for each row (i.e., forr=0, 1, . . . , N−1). The first register array S0 and the secondregister array S1 are defined respectively as:

-   -   S0[c, 0], S0[c, 1] for c=0, 1, . . . , M−1, and    -   S1[r, 0] for r=0, 1, . . . , N−1.        As shown in FIG. 17, the register array S0 includes values for        the same column and below the position of the value BR[i] being        coded, and the register array S1 includes a single value in the        same row and one column to the right of the position of the        value BR[i] being coded.

For coding a transform block of size M×N determined using TX_CLASS_2Dand a context corresponding to the two-dimensional template 907, a firstregister array S0 is defined for each column (i.e., for c=0, 1, . . . ,M−1), a second register array S1 is defined for each row (i.e., for r=0,1, . . . , N−1), and a third register array S2 is defined for eachdiagonal. The first register array S0, the second register array S1, andthe third register array S2 are defined respectively as:

-   -   S0[c, 0] for c=0, 1, . . . , M−1,    -   S1[r, 0] for r=0, 1, . . . , N−1, and    -   S2[d, 0] for d=0, 1, M+N−2.        In the foregoing definition of the third register array S2, d is        the index of the diagonal line, and can be determined based on        the row index [r] and the column index [c] as follows:    -   d=0, if r is equal to c, and    -   d=2*abs(r−c)+(r<c), if r is not equal to c.        In defining the index d, the code (r<c) evaluates to zero when        r<c is false and to one when r<c is true. Note that any        bijective mapping of (r−c) to {0, 1, . . . , M+N−2} can be used        to define the index d. In cases where negative indices are        allowed, r−c or c−r can be used directly as definition of the        index d.

As shown in FIG. 18, the first register array S0 includes values for thesame column and below the position of the value BR[i] being coded, thesecond register array S1 includes values for the same row and to theright of the position of the value BR[i] being coded, and the thirdregister array S2 includes a single value diagonally below and to theright of the position of the value BR[i] being coded.

At the beginning of coding a transform block, the register set isdefined according to the transform type that was used to determine thetransform coefficients for the transform block. Similar to thedescription above in regards to FIGS. 10-15, the values in the registerarrays of a register set for a current block being encoded or decodedare initially set to a default value (e.g., zero). The value BR[i] forthe transform coefficient at scan position i is a value from {0, 1, 2, .. . 12}. The block position corresponding to the scan position i isdenoted by row r_i and column c_i. In encoding, the value BR[i] beingcoded is obtained from base information, such as the level maps. Indecoding, the value BR[i] being coded is derived from the encodedbitstream using entropy coding The context to code the value BR[i] isdetermined by summing the values from the register arrays, whichrepresent the spatial context neighbors of the position of the valueBR[i] according to the template that corresponds to the transform type.

Referring to FIG. 16, if the transform type is one in TX_CLASS_HORIZ,the context used to code the value BL[i] is derived from:

-   -   S0[r_i, 0]+S0[r_i, 1]+S1[c_i, 0].        After the value BR[i] is coded, the register arrays are updated        as follows:    -   S0[r_i, 0]=BR[i],    -   S0[r_i, 1]=S0[r_i, 0], and    -   S1[c_i, 0]=BR[i].        For the register array S0, the first value S0[r_1, 0] is updated        to the value BR[i] that was just coded. The remaining value in        the register array S0 assumes the value from the preceding value        in the register array (i.e., the value in the register array is        shifted by one position). For the register array S1, the sole        value is updated to the value BR[i] that was just coded.

Referring to FIG. 17, if the transform type is one in TX_CLASS_VERT, thecontext used to code the value BR[i] is derived from:

-   -   S0[c_i, 0]+S0[c_i, 1]+S1[r_i, 0].        After the value BR[i] is coded, the register arrays are updated        as follows.    -   S0[c_i, 0]=BR[i],    -   S0[c_i, 1]=S0[c_i, 0], and    -   S1[r_i, 0]=BR[i].        For the register array S0, the first value S0[c_i, 0] is updated        to the value BR[i] that was just coded. The remaining value in        register array S0 assumes the value from the preceding value in        the register array (i.e., a value in the register array is        shifted by one position). In other words, the register array S0        is updated in a first-in-first-out (FIFO) manner by shifting out        the oldest value and adding the value BR[i] as the newest entry.        For the register array S1, the sole value is updated to the        value BR[i] that was just coded.

If the transform type is one in TX_CLASS_2D, the context used to codethe value BR[i] is derived from:

-   -   S0[c_i, 0]+S1[r_i, 0]+S2[d_i, 0].        After the value BR[i] is coded, the register arrays are updated        as follows.    -   S0[c_i, 0]=BR[i],    -   S1[r_i, 0]=BR[i], and    -   S2[d_i, 0]=BR[i], where    -   d_i=0 if (r_i==c_i), and    -   d_i=2*abs(r_i−c_i)+(r_i<c_i) if (r_i!=c_i).        In defining the index d, the code (r_i<c_i) evaluates to zero        when r_i<c_i is false and to one when r_i<c_i is true.

For the first register array S0, the sole value S0[c_i, 0] is updated tothe value BR[i] that was just coded. For the second register array S1,the sole value S1[r_i, 0] is updated to the value BR[i] that was justcoded. For the register array S2, the sole value is updated to the valueBR[i] that was just coded.

The implementations described with regards to FIGS. 13-18, as mentionedpreviously, avoids accessing previously coded base information, otherthan the value BL[i] or BR[i] being coded, to update shift registersafter coding. This eliminates the potentially costly access of the baseinformation as compared to the implementation of FIGS. 10-12. In orderto further reduce processing, a single register set that is suitable forall transform sizes and scan orders that similarly does not rely onlevel maps is a desirable variation.

According to such a further implementation, one or more spatialtemplates used for determining the context neighbors for the quantizedtransform coefficients may be selected. Selecting the one or morespatial templates may include determining the transform type(s)available to generate the quantized transform coefficients in thetransform block that is being coded. That is, the transform typesindicate what spatial templates may be used for selecting contextneighbors for coding one or more values representing the magnitude of atransform coefficient, here the value BL(i) and optionally the valueBR(i). According to the examples described herein, the transform typesmay be a one-dimensional horizontal transform type, such as one fromTX_CLASS_HORIZ, a one-dimensional vertical transform type, such as onefrom TX_CLASS_VERT, and a two-dimensional transform type, such as onefrom TX_CLASS_2D. The spatial templates of FIGS. 9A and 9B may be usedin this example.

The one or more spatial templates may be used to define the registerarrays. In the example where the spatial templates of FIGS. 9A and 9Bare available to the transform block being coded, a register set of 5register arrays are defined to derive context for base level symbols(i.e., BL[i]) and base range symbols (i.e., BR[i]). Defining theregister set includes determining the number and sizes of the registerarrays that form the register set. The number and sizes of the registerarrays may be defined based on the sizes and shapes of the spatialtemplates and the largest expected size M×N of the transform block.Generally, the cardinality (i.e., the number) of arrays may be equal tothe number of context neighbors defined in the spatial templates. Thecardinality of the register arrays may comprise one plus a largestnumber of context neighbors in a row or column of the one or morespatial templates. In the illustrated examples, the largest number ofcontext neighbors along the vertical or horizontal dimension is 4, andthe templates 903, 907 include a diagonal context. As a result, theregister set includes 5 register arrays.

The largest expected size M×N for a transform block may be used todefine sizes of the register arrays. For example the largest dimensionof the largest expected size may be used as the number of elements(i.e., context neighbor values) for 4 of the register arrays (where 4 isthe largest vertical or horizontal dimension of the spatial templates).In an example where the largest expected size (also referred to as thelargest transform size) is 32×32, 4 of the 5 register arrays have 32elements each. The number of elements (i.e., context neighbor values) ofthe fifth, final array is based on the expected number of diagonalelements for the largest transform size. In this example, the remainingarray has 63 elements in the range {0, 1, . . . , 62} according toR−C+31, where R comprises the row positions of the value BL or BR beingcoded in the range (0, 1, . . . , 31) and C comprises the columnpositions of the value BL or BR to be coded in the range (0, 1, . . . ,31). In some cases (e.g., in a software implementation as opposed to ahardware implementation), the remaining array may have 64 elements (moregenerally, a multiple of 2 elements) instead of 63 elements. Moregenerally, a single register array of the register arrays has a sizesufficient to store a number (i.e., a cardinality) of stored valuescorresponding to a number of values in a diagonal of a largest availabletransform size and remaining ones of the register arrays have an arraysize sufficient to store a number of stored values corresponding to alargest dimension of the largest available transform size.

In one example hardware implementation, the five register arrays aredefined as follows:

-   -   uai4 reg32_0[32],    -   uai4 reg32_1[32],    -   uai4 reg32_2[32],    -   uai4 reg32_3[32], and    -   uai4 reg64[63].

In the foregoing, uai4 indicates unsigned 4-bit integer type. In asoftware implementation, uai4 may be replaced by unsigned char orunsigned 8-bit integer type. That is, each element of a register arrayis sized to support at least one value, where the value is the largestexpected value to be coded. In the examples herein, the largest expectedvalue for the value BL is 3 and the largest expected value for the valueBR is 12. Accordingly, a 4-bit register array element may be used tostore one value, and an 8-bit register array element may be used tostore two values.

As with the other implementations described herein, at the beginning ofcoding a transform unit (or block), the register arrays are initializedto a default value, desirably 0. Deriving or determining the codingcontexts used to code one or more values for a transform coefficientthat indicate the magnitude of the transform coefficient at scanposition i, where (r_i, c_i) denotes the block position corresponding tothe scan position i following a given scan order, may be achieved usingthe defined register set. That is, the coding context may be determinedusing at least one of the stored values from the register arrays of theregister set.

In this example, the register arrays of the register set may be used tocompute two magnitude values, mag and br_mag, which are in turn used toderive the coding contexts for the value BL[i] and the value BR[i],respectively. The magnitude values mag and br_mag may be determinedbased on the transform type of the transform block being coded.

If the transform type is one in TX_CLASS_HORIZ, the magnitude values maybe determined according to the following pseudocode:

-   -   mag=MIN(reg32_0[r_i], uai4(3))+MIN(reg32_1[r_i],        uai4(3))+MIN(reg32_2[r_i], uai4(3))+MIN(reg32_3[r_i],        uai4(3))+MIN(reg64[c_i], uai4(3)); and    -   br_mag=reg32_0[r_i]+reg32_1[r_i]+reg64[c_i];    -   mag=MIN((mag+1)>>1, 4);    -   br_mag=MIN((br_mag+1)>>1, 6).

The function reg32_0[r_i] returns the value in the first register arrayreg32_0 at the array position corresponding to the row r_i, the functionreg32_1[r_i] returns the value in the second register array reg32_1 atthe array position corresponding to the row value r_i, the functionreg32_2[r_i] returns the value in the third register array reg32_2 atthe array position corresponding to the row value r_i, and the functionreg32_3[r_i] returns the value in the fourth register array reg32_3 atthe array position corresponding to the row value r_i. Similarly, thefunction reg64[c_i] returns the value in the fifth register array reg64at the array position corresponding to the column value c_i. Forexample, if the scan position i is at the block position (4, 0), thevalue at array position 4 in each of the first register array reg32_0,the second register array reg32_1, the third register array reg32_2, andthe fourth register array reg32_3 is returned by the functionreg32_0[r_i], the function reg32_1[r_i], the function reg32_2[r_i], andthe function reg32_3[r_i] respectively. Similarly, the functionreg64[c_i] returns the value at array position 0 in the fifth registerarray reg64.

The function uai4(3) returns the binary value for 3 in 4 bits, namely0011. The value 3 is used because it is the highest value for BL, and ishence the highest value for the context neighbors of BL(i). Inalternative implementations, this value may be different. The functionMIN(a, b) returns the smaller value between a and b. The functionoperator “>>” right-shifts a value by a designated number of bits, here1 bit). The calculations mag=MIN((mag+1)>>1, 4), andbr_mag=MIN((br_mag+1)>>1, 6) normalize the magnitude values for thedifferent transform types.

Using the same example as described above, and immediately afterinitialization (e.g., such that all values in the arrays are 0), themagnitude value mag is calculated as follows:

-   -   mag=MIN(0, 0011)+MIN(0, 0011)+MIN(0, 0011)+MIN(0, 0011)+MIN(0,        0011)=0;    -   mag=MIN((0+1)>>1, 4);    -   mag=MIN(0, 4); and    -   mag=0; and        the magnitude value br_mag is calculated as follows:    -   br_mag=0+0+0=0;    -   br_mag=MIN((0+1)>>1, 6);    -   br_mag=MIN(0, 6); and    -   br_mag=0.

If the transform type is one in TX_CLASS_VERT, the magnitude values maybe determined according to the following pseudocode:

-   -   mag=MIN(reg32_0[c_i], uai4(3))+MIN(reg32_1[c_i],        uai4(3))+MIN(reg32_2[c_i], uai4(3))+MIN(reg32_3[c_i],        uai4(3))+MIN(reg64[r_i], uai4(3));    -   br_mag=reg32_0[c_i]+reg32_1[c_i]+reg64[r_i];    -   mag=MIN((mag+1)>>1, 4);    -   br_mag=MIN((br_mag+1)>>1, 6).

The function reg32_0[c_i] returns the value in the first register arrayreg32_0 at the array position corresponding to the column value c_i, thefunction reg32_1[c_i] returns the value in the second register arrayreg32_1 at the array position corresponding to the column value c_i, thefunction reg32_2[c_i] returns the value in the third register arrayreg32_2 at the array position corresponding to the column value c_i, andthe function reg32_3[c_i] returns the value in the fourth register arrayreg32_3 at the array position corresponding to the column value c_i.Similarly, the function reg64[r_i] returns the value in the fifthregister array reg64 at the array position corresponding to the rowvalue r_i. For example, if the scan position i is at the block position(6, 2), the value at array position 6 (e.g., the seventh value) in eachof the first register array reg32_0, the second register array reg32_1,the third register array reg32_2, and the fourth register array reg32_3is returned by the function reg32_0[c_i], the function reg32_1[c_i], thefunction reg32_2[c_i], and the function reg32_3[c_i] respectively.Similarly, the function reg64[r_i] returns the value at array position 2(e.g., the third value) in the fifth register array reg64.

Using the example where the block position of the values BL[i] and BR[i]being coded is (6, 2), and assuming that the values atreg32_0[c_i]=reg32_0[2]=4 and reg32_1[c_i]=reg32_1[2]=4, and the valuesat the remaining array positions have a value of 0, the magnitude valuemag is calculated as follows:

-   -   mag=MIN(0100, 0011)+MIN(0100, 0011)+MIN(0, 0011)+MIN(0,        0011)+MIN(0, 0011);    -   mag=0011+0011+0+0+0=0110;    -   mag=MIN((0110+1)>>1, 4);    -   mag=MIN(0111>>1, 4);    -   mag=MIN(0011, 4); and    -   mag=0011=3; and        the magnitude value br_mag is calculated as follows:    -   br_mag=0100+0100+0=1000;    -   br_mag=MIN((1000+1)>>1, 6);    -   br_mag=MIN((1001)>>1, 6);    -   br_mag=MIN(0100, 6); and    -   br_mag=0100=4.

If the transform type is one in TX_CLASS_2D, the magnitude values may bedetermined according to the following pseudocode:

-   -   mag=MIN(reg32_0[c_i], uai4(3))+MIN(reg32_1[c_i],        uai4(3))+MIN(reg32_2[r_i], uai4(3))+MIN(reg32_3[r_i],        uai4(3))+MIN(reg64[diag], uai4(3));    -   br_mag=reg32_0[c_i]+reg32_2[r_i]+reg64[diag];    -   mag=MIN((mag+1)>>1, 4);    -   br_mag=MIN((br_mag+1)>>1, 6).

In the foregoing, diag=r_i−c_i+31, and is the index for the fifthregister array reg64. Accordingly, the function reg64[diag] returns thevalue in the fifth register array at the array position corresponding tothe index value diag. The calculations are performed similarly to thosewhere the transform type is one in TX_CLASS_HORIZ or TX_CLASS_VERT.

Summarizing the above, determining the coding context using at leastsome of the stored values includes determining, based on a transformtype used for the transform block, a respective index for each of theregister arrays using a column and/or a row of the scan position. Astored value from each of the register arrays to determine the codingcontext is then selected using a respective index of each of theregister arrays. Selected stored values from each of the register arraysare summed to generate a first magnitude value (e.g., mag), whilelimiting each of the selected stored values to a first maximum value(e.g., 3) while summing. Then, the first magnitude value is normalized.Similarly, a stored values from fewer that each of the register arraysare summed to generate a second magnitude value (e.g., br_mag). Then,the second magnitude value is normalized. Subsequently, and as describedbelow, a first coding context for entropy coding a first value for thetransform coefficient (e.g., BL[i]) indicative of a magnitude of thetransform coefficient that is no greater than the first maximum value(e.g., 3) may be determined using the normalized first magnitude value,and a second coding context for entropy coding a second value (e.g.,BR[i]) for the transform coefficient indicative of the magnitude of thetransform coefficient that is up to a second maximum value (e.g., 12) isdetermined using the normalized second magnitude value.

Once the magnitude value mag is obtained, a context offset ctx_offsetused to code the value BL[i] may be determined, also based on thetransform type. If the transform type is one in TX_CLASS_2D, thefollowing pseudocode may be used to determine ctx_offset:

-   -   if (r_i==0 && c_i==0) ctx_offset=0;    -   else if (w<h && r_i<2) ctx_offset=11+mag;    -   else if (w>h && c_i<2) ctx_offset=16+mag;    -   else if (r_i+c_i<2) ctx_offset=mag+1;    -   else if (r_i+c_i<4) ctx_offset=5+mag+1;    -   else ctx_offset=21+mag.

Herein, w is the width of the transform block being coded, h is theheight of the transform block being coded, == is a Boolean operator suchthat (a==b) evaluates to true when a=b and otherwise evaluates to false,and && is a Boolean operator such that (a && b) evaluates to true when aand b are true and evaluates to false when either a or b is false.Accordingly, the value of ctx_offset is based on the value of r_i andc_i. The value of ctx_offset is based on the width and height of thetransform block being coded. If r_i and c_i are both equal to 0,ctx_offset is equal to zero. If r_i or c_i or both are not equal to 0,the remaining conditions are considered in order. Once a value isdetermined for ctx_offset in response to a condition, further processingof the conditions ends. For example, if w is less than h, but r_i is notless than 2, the next condition (i.e., whether (w>h && c_i<2) evaluatesto true) is considered. On the other hand, if w is less than h, and r_iis less than 2, ctx_offset is equal to 11+mag. The next condition (i.e.,whether (w>h && c_i<2) evaluates to true) is not considered, nor are thesubsequent conditions.

If the transform type is one in TX_CLASS_VERT, the following pseudocodemay be used to determine ctx_offset:

-   -   if (r_i==0) ctx_offset=26+mag;    -   else if (r_i<2) ctx_offset=26+5+mag;    -   else ctx_offset=26+10+mag.

If the transform type is one in TX_CLASS_HORIZ, the following pseudocodemay be used to determine ctx_offset:

-   -   if (c_i==0) ctx_offset=26+mag;    -   else if (c_i<2) ctx_offset=26+5+mag;    -   else ctx_offset=26+10+mag.

Once the magnitude value br_mag is obtained, a context offsetbr_ctx_offset used to code BR[i] may be determined. If r_i and c_i areboth equal to zero, the context coefficient br_ctx_offset is set equalto the magnitude value br_mag. Otherwise, the context coefficientbr_ctx_offset is based on the transform type. If the transform type isone in TX_CLASS_2D, the context coefficient br_ctx_offset is set tobr_mag+7 if r_i and c_i are both less than 2. Otherwise, the contextcoefficient br_ctx_offset is set to br_mag+14. If the transform type isone in TX_CLASS_HORIZ, the context coefficient br_ctx_offset is set tobr_mag+7 if c_i is equal to 0. Otherwise, the context coefficientbr_ctx_offset is set to br_mag+14. Finally, if the transform type is onein TX_CLASS_VERT, the context coefficient br_ctx_offset is set tobr_mag+7 if r_i is equal to 0. Otherwise, the context coefficientbr_ctx_offset is set to br_mag+14.

The context offset ctx_offset is used, along with other information liketransform size and whether the transform block is a luma or chromablock, to determine a context for the value BL[i]. As is conventional, acontext specifies the probability distribution used in arithmeticcoding. In the case for the value BL[i], the probability distribution isa 4-tuple. On the encoder side, arithmetic encoding codes the valueBL[i] into a binary codeword by using the probability distribution givenby the context. On the decoder side, arithmetic decoding decodes thevalue BL[i] from a binary codeword and the probability distribution. Thecontext offset br_ctx_offset is similarly used to determine a contextfor the value BR[i].

After the values BL[i] and BR[i] are coded, the register arrays areupdated to prepare for context derivation at scan position i−1 if i>0.In the following, level=BL[i] if BL[i]<3, and level=3+BR[i] if BL[i]=3.The register arrays may be updated as shown in the following pseudocodedepending upon the transform type of the transform block:

where the transform type is one in TX_CLASS_HORIZ:

-   -   reg32_3[r_i]=reg32_2[r_i];    -   reg32_2[r_i]=reg32_1[r_i];    -   reg32_1[r_i]=reg32_0[r_i];    -   reg32_0[r_i]=level;    -   reg64[c_i]=level;

where the transform type is one in TX_CLASS_VERT:

-   -   reg32_3[c_i]=reg32_2[c_i];    -   reg32_2[c_i]=reg32_1[c_i];    -   reg32_1[c_i]=reg32_0[c_i];    -   reg32_0[c_i]=level;    -   reg64[r_i]=level;

where the transform type is one in TX_CLASS_2D:

-   -   reg32_1[c_i]=reg32_0[c_i];    -   reg32_0[c_i]=level;    -   reg32_3[r_i]=reg32_2[r_i];    -   reg32_2[r_i]=level;    -   reg64[diag]=level.

In summary, where the transform type is one of TX_CLASS_HORIZ, thevalues in the first register array at position r_i reg32_0[r_i] and thefifth register array at position c_i reg64[c_i] are updated to level,which value is based on the value BL[i] that was just coded as describedabove. The value in the second register array at position r_ireg32_1[r_i] is updated to the value in the first register array atposition r_i reg32_0[r_i]. The remaining values in the remainingregister arrays at position r_i assume the values from the precedingregister array at position r_i. That is, values in the register arrayare shifted by one array position. In the implementations previouslydescribed, the array position shift is a shift in position within anarray. In this implementation, the array position shift is a shift inposition between arrays.

Similarly, where the transform type is one of TX_CLASS_VERT, the valuesin the first register array at position c_i reg32_0[c_i] and the fifthregister array at position r_i reg64[r_i] are updated to level, whichvalue is based on the value at the position that was just coded BL[i] asdescribed above. The value in the second register array at position c_ireg32_1[c_i] is updated to the value in the first register array atposition c_i reg32_0[r_i]. The remaining values in the remainingregister arrays at position c_i assume the values from the precedingregister array at position c_i (i.e., values in the register array areshifted by one array position).

Finally, where the transform type is one of TX_CLASS_2D, the values inthe first register array at position c_i reg32_0[c_i], the thirdregister array at position r_i, and the fifth register array at positiondiag reg64[diag] are updated to level, which value is based on the valueBL[i] that was just coded as described above. The value in the secondregister array at position c_i reg32_1[c_i] is updated to the value inthe first register array at position c_i reg32_0[r_i]. The remainingvalue in the fourth register array at position r_i assumes the valuefrom the preceding (third) register array at position r_i reg32_2[r_i].As with the other transform types, values in the register array areshifted by one array position.

Note that this solution may be described as universal in the sense thatit can be applied to any transform size and any scan order. With thissolution, there is also no need to pad a transform (to the right andbelow) to derive contexts for symbols at the right and bottom boundaryof a transform as needed in storing neighborhood positions—padding isreplaced by simply initializing the arrays to 0.

FIG. 19 is a flowchart diagram of a process for coding a transform blockaccording to an implementation of this disclosure. The process 1900 canbe implemented in an encoder such as the encoder 400. In animplementation, the process 1900 is utilized in the process 800, forexample, to implement coding of the value BL[i] in operation 802, thecoding of the value BR[i] in operation 803, or both.

The process 1900 can be implemented, for example, as a software programthat can be executed by computing devices such as transmitting station102. The software program can include machine-readable instructions thatcan be stored in a memory such as the memory 204 or the secondarystorage 214, and that can be executed by a processor, such as CPU 202,to cause the computing device to perform the process 1900. In at leastsome implementations, the process 1900 can be performed in whole or inpart by the entropy encoding stage 408 of the encoder 400.

The process 1900 can be implemented using specialized hardware orfirmware. Some computing devices can have multiple memories, multipleprocessors, or both. The steps or operations of the process 1900 can bedistributed using different processors, memories, or both. Use of theterms “processor” or “memory” in the singular encompasses computingdevices that have one processor or one memory as well as devices thathave multiple processors or multiple memories that can be used in theperformance of some or all of the recited steps.

The process 1900 can receive information that describes the magnitudesof transform coefficients. For example, the process 1900 can receive atransform block, such as the transform block 704, or level maps thatrepresent values from the transform block 704, such as the non-zero map708, the level-1 map 712, and the level-2 map 714.

In operation 1901, one or more spatial templates for a coding contextmay be determined or selected. This determination can be made based onthe transform type that was used to determine the quantized transformcoefficients in the transform block that is being coded. The spatialtemplates are spatial arrangements of cells, anchored at the value beingcoded at the current scan position, from which the coding context isdetermined. The templates may be horizontal, vertical, ortwo-dimensional templates, selected on the basis of use of aone-dimensional horizontal transform type, such as one fromTX_CLASS_HORIZ, a one-dimensional vertical transform type, such as onefrom TX_CLASS_VERT, or a two-dimensional transform type, such as onefrom TX_CLASS_2D, respectively. Thus, each of a plurality of differentlytransform types may correspond to selection of a different spatialtemplate. Examples of spatial templates that can be selected inoperation 1901 include the horizontal templates 901, 905, the verticaltemplate 902, 906, and the two-dimensional template 903, 907.

In some implementations, the spatial template for the coding contextcorresponds to an area that includes positions from at least two rowsand positions from at least two columns, and a top-left position of thespatial template corresponds to the scan position. The transform typemay be a horizontal transform type, a vertical transform type, atwo-dimensional transform type, or any combination thereof.

In implementations such as those described with regard to FIGS. 10-18,only one template may be selected for each of the determination of acontext for coding the value BL, and where applicable the value BR. Inan implementation such as the universal solution described above, allavailable templates may be selected. According to a variation in thisimplementation, all available templates for only the transform type maybe selected. The selection of one or more templates at 1901 may beomitted where, for example all available templates are used, as thetemplates may be known a priori.

A spatial template determined in operation 1901 may include pluralvalues from a same row as the scan position and a single value from asame column as the scan position when the transform type is thehorizontal transform type. A spatial template selected in operation 1901may include plural values from a same column as the scan position and asingle value from a same row as the scan position when the transformtype is the vertical transform type. A spatial template selected inoperation 1901 may include plural values from a same column as the scanposition, plural values from a same row as the scan position, and asingle value from a same diagonal as the scan position when thetransform type is the two-dimensional transform type.

In operation 1902, register arrays are defined to hold values for thecoding context. The values held in the register arrays may be referredto herein as stored values. The register arrays are defined based on, atleast in part, the geometry of the spatial template(s) selected inoperation 1901. For example, the values in the register arrays may eachcorrespond to a position in the spatial template selected in operation1901. By defining the register arrays to correspond to a geometricarrangement of the spatial template, the stored values from the registerarrays will each correspond to a respective position from the spatialtemplate, and a particular value in each register array position willtherefore correspond to a particular spatial location within the spatialtemplate. The values for the spatial template are stored in two or moreregister arrays, which each can hold values for a single row, column, ordiagonal of the spatial template. The register arrays may eachcorrespond to a column index, a row index, or a diagonal index of thetransform block. The register arrays can be defined, for example, asdescribed with reference to the examples shown in FIGS. 10-18.

The register arrays may be defined at operation 1902 based on thegeometry of the spatial templates and based on the largest availabletransform size. As described previously, the largest available transformsize may be 32×32. The cardinality or number of register arrays may bedefined by an array that has a size sufficient to store a number ofvalues corresponding to the largest number of values in a diagonal ofthe largest available transform size and a number of arrays thatcorrespond to the larger number of the largest number of columns or thelargest number of rows of the spatial templates determined at 1901,where each of the latter register arrays has an array size sufficient tostore a number of values corresponding to the larger of the largestnumber of columns or the largest number of rows of the largest availabletransform size. In an example where the largest available transform sizeis 32×32, and the largest number of columns and the largest number ofrows in the spatial templates are both equal to 4, there are fiveregister arrays—4 having an array size (number of elements) of 32, andone having an array size of 63 (or 64 where processing makes an arraysize of 2^(n) desirable).

In operation 1903, the register arrays are initialized. Initializing theregister arrays can include setting all of the values in the registerarrays to a default value, such as zero.

In operation 1904, entropy coding of values for transform coefficientsindicative of magnitudes of the transform coefficients from thetransform block begins by setting the scan position to a next positionto be coded, referred to herein as the scan position i. Various scanorders may be used for predicting a block that is used to produce thetransform block. Entropy coding is performed using the reverse of thisscan order (referred to herein as a reverse scan order). Therefore, thefirst position to be coded corresponds to the first non-zero value thatappears in the reverse scan order. In subsequent iterations, the scanposition is decremented in operation 1904, such that operations1905-1908 are performed again, which continues until all of the valuesfrom the transform block are coded.

In operation 1905, a value for the transform coefficient being coded isobtained. The value is indicative of a magnitude of the transformcoefficient at the current scan position i within the current transformblock being coded. The value may be obtained from the transform block704 and/or from level maps that represent the transform block. Forexample, the value being coded may be a single value corresponding to BLor BR, or may be two values corresponding to BL and BR.

In operation 1906, the coding context is determined using the valuesfrom the register arrays. As an example, the coding context may bedetermined by summing values from the register arrays, as described withreference to FIGS. 10-18. In the further example such as that describedabove, the coding context for BL may be determined by summing valuesfrom the register arrays after those values are compared to the highestvalue for BL. The lower values from each of the comparisons are summed,and used to generate a magnitude value mag that is used to generate thecoding context, a context offset ctx_offset. The coding context for BRmay be determined by summing values from fewer than all of the registerarrays, which sum is then used to generate a magnitude value br_mag forgenerating the coding context, a context offset br_ctx_offset. Thecoding contexts ctx_offset and br_ctx_offset also depend upon the scanposition (r_i, c_i, or both). When the transform type is one inTX_CLASS_2D, the coding context ctx_offset may also depend upon thedimensions of the transform block (the width, the height, or both).

In some implementations, in operation 1906, determining the codingcontext using the stored values from the register arrays includesselecting one or more register array positions that correspond to one ofthe column index, the row index, or the diagonal index for the scanposition.

Operation 1907 includes entropy coding the one or more values (BL, BR,or both) using the coding context that was determined in operation 1906.In particular, the coding context is used to select a statistical modelfor use in entropy coding, which is then performed, for example, asdescribed with respect to the entropy encoding stage 408 of the encoder400. The output of operation 1907 may be inserted into an encodedbitstream.

Subsequent to entropy coding the value in operation 1907, at least someof the stored values in the register arrays are updated in operation1908. Updating at least some of the stored values in the register arraysmay include shifting one or more values by one register array position.This shifting may occur between register array positions within a singleregister array. The shifting may occur between register array positionsof two register arrays. The register array positions of the two registerarrays may be the same position (e.g., a common index or the sameregister index) in the two register arrays. That is, for example,shifting one or more stored values may comprise shifting the one or morestored values from an array position at an index within a first registerarray to an array position at a common index within a second registerarray.

Updating at least some of the stored values in the register arrays mayinclude setting one or more values in the register arrays equal to thevalue that was coded in operation 1907. Where a single set of registerarrays are used to determine a coding context for both values BL[i] andBR[i] at scan position i, updating at least some of the stored values inthe register arrays may include setting one or more values in theregister arrays equal to the value BL[i] that was coded in operation1907 as long as the value BL[i] is less than the maximum value for BL[i](e.g., 3) and otherwise setting the one or more values in the registerarrays equal to the value BR[i] plus the maximum value for the valueBL[i].

In some implementations, updating at least some of the stored values inthe shift registers includes obtaining information from the valuesindicative of the magnitudes of the transform coefficients from thetransform block. These values (like the values BL and BR) may be thetransform coefficient values themselves, absolute values of thetransform coefficients, and/or values from level maps. The values may benumbers or may be expressions, such as Boolean expressions. For example,the values can indicate whether the absolute value of each transformcoefficient is equal to zero, equal to one, equal to two, or is greaterthan or equal to three.

In operation 1909, a determination is made as to whether more valuesremain to be coded. For example, if the most recent operation of 1907coded scan position i=0, it can be determined that no more values remainto be coded, and the process 1900 ends for the current transform block.Otherwise, the process returns to operation 1904, where the scanposition is set to the next position in the reverse scan order, andoperations 1905 through 1909 are performed again for value of the newscan position. The process 1900 may be repeated for multiple transformblocks of a frame.

As is clear from the description of operations 1905 and 1907, theprocess 1900 may be used for entropy encoding transform coefficients ofa transform block. FIG. 20 is a flowchart diagram of a process forcoding a transform block according to another implementation of thisdisclosure. The process 2000 can be implemented in a decoder such as thedecoder 500. In an implementation, the process 2000 is utilized in theprocess 800, for example, to implement coding of the value BL[i] inoperation 802, the coding of the value BR[i] in operation 803, or both.

The process 2000 can be implemented, for example, as a software programthat can be executed by computing devices such as receiving station 106.The software program can include machine-readable instructions that canbe stored in a memory such as the memory 204 or the secondary storage214, and that can be executed by a processor, such as CPU 202, to causethe computing device to perform the process 2000. In at least someimplementations, the process 1900 can be performed in whole or in partby the entropy decoding stage 502 of the decoder 500.

The process 2000 can be implemented using specialized hardware orfirmware. Some computing devices can have multiple memories, multipleprocessors, or both. The steps or operations of the process 2000 can bedistributed using different processors, memories, or both.

The process 2000 can receive information that describes the magnitudesof transform coefficients. For example, the process 2000 can receive aportion of an encoded bitstream that includes an encoded transformblock, such as the transform block 704, or encoded level maps thatrepresent values from the transform block 704, such as the non-zero map708, the level-1 map 712, and the level-2 map 714.

In operation 2001, one or more spatial templates for a coding contextare determined or selected. The operation 2001 may be the same as theoperation 1901 described above.

In operation 2002, register arrays are defined to hold stored values forthe coding context. The operation 2002 may be the same as the operation1902 described above.

In operation 2003, the register arrays are initialized. Initializing theregister arrays can include setting all of the values in the registerarrays to a default value, such as zero, as described above with regardto operation 1903.

In operation 2004, entropy coding of values for transform coefficientsindicative of magnitudes of the transform coefficients from thetransform block begins by setting the scan position to the next position(e.g., in reverse scan order starting at the first non-zero value asdescribed with regard to operation 1904.

In operation 2006, the coding context is determined using the valuesfrom the register arrays. The operation 2006 may be the same as theoperation 1906 described above.

Operation 2007 includes entropy coding the one or more values (BL, BR,or both) for the transform coefficient at the scan position i set atoperation 2004. Entropy coding is performed using the coding contextthat was determined in operation 2006 with the encoded bitstream, suchas the compressed bitstream 420, as input. The coding context, togetherwith other information such as transform block size, prediction mode,etc., is used to select a statistical model for use in entropy coding.Entropy coding may be performed, for example, as described with respectto the entropy decoding stage 502 of the encoder 400. The output ofoperation 2007 is the value or values for the transform coefficient atthe scan position i. For example, the process 2000 may be used to codethe values BL and BR as described in operation 802 and 803, which valuesare then combined to produce the transform coefficient once the process800 is completed for a transform coefficient.

Subsequent to entropy coding the one or more values for the transformcoefficient in operation 2007, at least some of the stored values in theregister arrays are updated in operation 2008. Updating at least some ofthe stored values in the register arrays in operation 2008 may beperformed the same as the updating in operation 1908 described above.

In operation 2009, a determination is made as to whether more valuesremain to be coded. For example, if the most recent operation of 2007coded values at scan position i=0, the process 2000 ends for the currenttransform block. Otherwise, the process 2000 returns to operation 2004,where the scan position is set to the next position in the reverse scanorder. Operations 2006 through 2009 are performed again for values oftransform coefficients of the new scan position. The process 2000 may berepeated for multiple transform blocks of a frame.

The aspects of encoding and decoding described above illustrate someencoding and decoding techniques. However, it is to be understood thatencoding and decoding, as those terms are used in the claims, could meancompression, decompression, transformation, or any other processing orchange of data.

The words “example” or “implementation” are used herein to mean servingas an example, instance, or illustration. Any aspect or design describedherein as “example” or “implementation” is not necessarily to beconstrued as preferred or advantageous over other aspects or designs.Rather, use of the words “example” or “implementation” is intended topresent concepts in a concrete fashion. As used in this application, theterm “or” is intended to mean an inclusive “or” rather than an exclusive“or”. That is, unless specified otherwise, or clear from context, “Xincludes A or B” is intended to mean any of the natural inclusivepermutations. That is, if X includes A; X includes B; or X includes bothA and B, then “X includes A or B” is satisfied under any of theforegoing instances. In addition, the articles “a” and “an” as used inthis application and the appended claims should generally be construedto mean “one or more” unless specified otherwise or clear from contextto be directed to a singular form. Moreover, use of the term “animplementation” or “one implementation” throughout is not intended tomean the same embodiment or implementation unless described as such.

Implementations of transmitting station 102 and/or receiving station 106(and the algorithms, methods, instructions, etc., stored thereon and/orexecuted thereby, including by encoder 400 and decoder 500) can berealized in hardware, software, or any combination thereof. The hardwarecan include, for example, computers, intellectual property (IP) cores,application-specific integrated circuits (ASICs), programmable logicarrays, optical processors, programmable logic controllers, microcode,microcontrollers, servers, microprocessors, digital signal processors orany other suitable circuit. In the claims, the term “processor” shouldbe understood as encompassing any of the foregoing hardware, eithersingly or in combination. The terms “signal” and “data” are usedinterchangeably. Further, portions of transmitting station 102 andreceiving station 106 do not necessarily have to be implemented in thesame manner.

Further, in one aspect, for example, transmitting station 102 orreceiving station 106 can be implemented using a general purposecomputer or general purpose processor with a computer program that, whenexecuted, carries out any of the respective methods, algorithms and/orinstructions described herein. In addition, or alternatively, forexample, a special purpose computer/processor can be utilized which cancontain other hardware for carrying out any of the methods, algorithms,or instructions described herein.

Transmitting station 102 and receiving station 106 can, for example, beimplemented on computers in a video conferencing system. Alternatively,transmitting station 102 can be implemented on a server and receivingstation 106 can be implemented on a device separate from the server,such as a hand-held communications device. In this instance,transmitting station 102 can encode content using an encoder 400 into anencoded video signal and transmit the encoded video signal to thecommunications device. In turn, the communications device can thendecode the encoded video signal using a decoder 500. Alternatively, thecommunications device can decode content stored locally on thecommunications device, for example, content that was not transmitted bytransmitting station 102. Other transmitting station 102 and receivingstation 106 implementation schemes are available. For example, receivingstation 106 can be a generally stationary personal computer rather thana portable communications device and/or a device including an encoder400 may also include a decoder 500.

Further, all or a portion of implementations of the present disclosurecan take the form of a computer program product accessible from, forexample, a tangible computer-usable or computer-readable medium. Acomputer-usable or computer-readable medium can be any device that can,for example, tangibly contain, store, communicate, or transport theprogram for use by or in connection with any processor. The medium canbe, for example, an electronic, magnetic, optical, electromagnetic, or asemiconductor device. Other suitable mediums are also available.

The above-described embodiments, implementations and aspects have beendescribed in order to allow easy understanding of the present disclosureand do not limit the present disclosure. On the contrary, the disclosureis intended to cover various modifications and equivalent arrangementsincluded within the scope of the appended claims, which scope is to beaccorded the broadest interpretation so as to encompass all suchmodifications and equivalent structure as is permitted under the law.

What is claimed is:
 1. A method of coding a transform block havingtransform coefficients, comprising: defining, based on at least onespatial template for a coding context, register arrays to each hold oneor more stored values regarding the coding context, wherein the registerarrays include at least a first register array that has a first size anda second register array that has a second size that is different thanthe first size; initializing the register arrays by setting the storedvalues to default values; and coding, in a reverse scan order, valuesfor the transform coefficients from the transform block that areindicative of magnitudes of the transform coefficients, the codingincluding, for each of one or more transform coefficients: determiningthe coding context using at least some of the stored values from theregister arrays, entropy coding a value for the transform coefficient ata scan position using the coding context, and subsequent to entropycoding the value for the transform coefficient, updating the registerarrays.
 2. The method of claim 1, wherein: a cardinality of the registerarrays comprises one plus a largest number of context neighbors in a rowor column of the at least one spatial template; and the register arrayscomprise: a single register array of the register arrays having an arraysize sufficient to store a number of stored values corresponding to anumber of values in a diagonal of a largest available transform size;and remaining ones of the register arrays having an array sizesufficient to store a number of stored values corresponding to a largestdimension of the largest available transform size.
 3. The method ofclaim 2, wherein: the cardinality of the register arrays is 5; thesingle register array has an array size that stores at least 63 values;and the remaining ones of the register arrays each have an array sizethat stores 32 values.
 4. The method of claim 1, further comprising:selecting, based on a transform type used for the transform block, theat least one spatial template for the coding context, wherein the atleast one spatial template comprises a first spatial template for afirst value at the scan position indicative of a magnitude of a currenttransform coefficient of the transform block and a second spatialtemplate for a second value at the scan position indicative of themagnitude of the current transform coefficient, the first spatialtemplate different from the second spatial template, and wherein:entropy coding the value for the transform coefficient comprises entropycoding the first value and entropy coding the second value, whereinentropy coding the first value uses a different coding context thanentropy coding the second value.
 5. The method of claim 4, wherein thefirst value is less than or equal to a first maximum value for themagnitude, and the second value is less than or equal to a secondmaximum value, the first maximum value less than the second maximumvalue.
 6. The method of claim 1, wherein the register arrays correspondto a geometric arrangement of the at least one spatial template, suchthat the stored values from the register arrays each correspond to arespective position from the at least one spatial template.
 7. Themethod of claim 1, wherein the register arrays comprise a set ofregister arrays, and determining the coding context comprisesdetermining two coding contexts using the set of register arrays, eachof the two coding contexts for entropy coding a respective value for thetransform coefficient at the scan position.
 8. The method of claim 1,wherein updating the register arrays includes shifting one or morestored values by one array position.
 9. The method of claim 8, whereinshifting one or more stored values by one array position comprisesshifting the one or more stored values by one array position within asingle register array of the register arrays.
 10. The method of claim 8,wherein shifting one or more stored values by one array positioncomprises shifting the one or more stored values from an array positionat an index within a first register array to an array position at acommon index within a second register array.
 11. An apparatus for codinga transform block having transform coefficients, comprising: a memory;and a processor configured to execute instructions stored in the memoryto: define, based on at least one spatial template for a coding context,register arrays to each hold one or more stored values regarding thecoding context, wherein the register arrays include at least a firstregister array that has a first size and a second register array thathas a second size that is different than the first size; initialize theregister arrays by setting the stored values to default values; andcode, in a reverse scan order, values for the transform coefficientsfrom the transform block that are indicative of magnitudes of thetransform coefficients, wherein the instructions to code includeinstructions to, for each of one or more transform coefficients:determine the coding context using at least some of the stored valuesfrom the register arrays, entropy code a value for the transformcoefficient at a scan position using the coding context, and subsequentto entropy coding the value for the transform coefficient, update theregister arrays.
 12. The apparatus of claim 11, wherein instructions toupdate the register arrays includes setting one or more stored values inthe register arrays equal to the value for the transform coefficient.13. The apparatus of claim 11, wherein the instructions for entropycoding the value comprise instructions to: entropy code a first valueindicative of a magnitude of the transform coefficient, the first valuebelonging to a set of positive integers {0, . . . , a first maximumvalue}, and entropy code a second value indicative of the magnitude ofthe transform coefficient, the second value belonging to a set ofpositive integers {0, . . . , a second maximum value}, and the secondmaximum value is greater than the first maximum value; and whereininstructions to update at least some of the stored values in theregister arrays includes: setting one or more values in the registerarrays equal to the first value when the first value is less than thefirst maximum value, and otherwise setting the one or more values in theregister arrays equal to a sum of the first value and the second value.14. The apparatus of claim 11, wherein the instructions to determine thecoding context using at least some of the stored values from theregister arrays comprises instructions to: determine, based on atransform type used for the transform block, a respective index for eachof the register arrays using at least one of a column and a row of thescan position; and select, from each of the register arrays using itsrespective index, a stored value to determine the coding context. 15.The apparatus of claim 14, wherein the instructions to determine thecoding context using at least some of the stored values from theregister arrays comprises instructions to: sum selected stored valuesfrom each of the register arrays to generate a first magnitude value,wherein each selected stored value is limited to a first maximum valuewhile summing; normalize the first magnitude value; determine, using thenormalized first magnitude value, a first coding context for entropycoding a first value for the transform coefficient indicative of amagnitude of the transform coefficient that is no greater than the firstmaximum value; sum selected stored values from fewer than all of theregister arrays to generate a second magnitude value; normalize thesecond magnitude value; and determine, using the normalized secondmagnitude value, a second coding context for entropy coding a secondvalue for the transform coefficient indicative of the magnitude of thetransform coefficient that is up to a second maximum value.
 16. Anapparatus for coding a transform block having transform coefficients,comprising: a memory; and a processor configured to execute instructionsstored in the memory to: define, based on at least one spatial templatefor a coding context, register arrays to each hold one or more storedvalues regarding the coding context; initialize the register arrays bysetting the stored values to default values; and code values, in areverse scan order, for the transform coefficients of the transformblock indicative of magnitudes of the transform coefficients, includinginstructions to: determine a first coding context using at least some ofthe stored values from the register arrays, entropy code a first valuefor the transform coefficient using the first coding context, the firstvalue indicative of a magnitude of the transform coefficient, and thefirst value belonging to a set of positive integers {0, . . . , a firstmaximum value}, determine a second coding context using at least some ofthe stored values from the register arrays, entropy code a second valuefor the transform coefficient using the second coding context, thesecond value indicative of the magnitude of the transform coefficient,the second value belonging to a set of positive integers {0, . . . , asecond maximum value}, and the second maximum value greater than thefirst maximum value, and subsequent to entropy coding the first valueand the second value, update the register arrays.
 17. The apparatus ofclaim 16, wherein the instructions to determine the first coding contextcomprises instructions to: sum respective stored values from each of theregister arrays to generate a first magnitude value, wherein each storedvalue is limited to a first maximum value while summing; normalize thefirst magnitude value; and determine, using the normalized firstmagnitude value, the first coding context; and wherein the instructionsto determine the first coding context comprises instructions to: sumrespective stored values from fewer than all of the register arrays togenerate a second magnitude value; normalize the second magnitude value;and determine, using the normalized second magnitude value, the secondcoding context.
 18. The apparatus of claim 16, wherein: a cardinality ofthe register arrays comprises one plus a number that corresponds to alarger number of a largest number of columns or a largest number of rowsof the at least one spatial template; and the register arrays comprise:a single register array of the register arrays having an array sizesufficient to store a number of stored values corresponding to a numberof values in a diagonal of a largest available transform size; andremaining ones of the register arrays having an array size sufficient tostore a number of stored values corresponding to a largest dimension ofthe largest available transform size.
 19. The apparatus of claim 16,wherein the instructions to update the register arrays comprisesinstructions to: shift one or more stored values from an array positionat an index within a first register array to an array position at acommon index within a second register array; and set one or more storedvalues in the register arrays equal to the first value when the firstvalue is less than the first maximum value, and otherwise setting theone or more stored values in the register arrays equal to a sum of thefirst value and the second value.